Skip to content

Commit

Permalink
chore: remove mongo preview (#12660)
Browse files Browse the repository at this point in the history
  • Loading branch information
millsp committed Apr 4, 2022
1 parent 17b5415 commit 401df2e
Show file tree
Hide file tree
Showing 29 changed files with 733 additions and 950 deletions.
6 changes: 3 additions & 3 deletions packages/cli/package.json
Expand Up @@ -68,9 +68,9 @@
"devDependencies": {
"@prisma/client": "workspace:*",
"@prisma/debug": "workspace:*",
"@prisma/fetch-engine": "3.12.0-35.7e91d3111425c8915dcdd8e37bca69ddcb2c883d",
"@prisma/fetch-engine": "3.12.0-36.4c0f1c1c0d2a8371bb5d9c4d759305e171b5411a",
"@prisma/generator-helper": "workspace:*",
"@prisma/get-platform": "3.12.0-35.7e91d3111425c8915dcdd8e37bca69ddcb2c883d",
"@prisma/get-platform": "3.12.0-36.4c0f1c1c0d2a8371bb5d9c4d759305e171b5411a",
"@prisma/migrate": "workspace:*",
"@prisma/sdk": "workspace:*",
"@prisma/studio": "0.459.0",
Expand Down Expand Up @@ -119,7 +119,7 @@
"preinstall": "node scripts/preinstall-entry.js"
},
"dependencies": {
"@prisma/engines": "3.12.0-35.7e91d3111425c8915dcdd8e37bca69ddcb2c883d"
"@prisma/engines": "3.12.0-36.4c0f1c1c0d2a8371bb5d9c4d759305e171b5411a"
},
"sideEffects": false
}
25 changes: 4 additions & 21 deletions packages/cli/src/Init.ts
Expand Up @@ -19,23 +19,7 @@ import { isError } from 'util'
import { printError } from './utils/prompt/utils/print'

export const defaultSchema = (provider: ConnectorType = 'postgresql') => {
// add preview flag
if (provider === 'mongodb') {
return `// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
generator client {
provider = "prisma-client-js"
previewFeatures = ["mongoDb"]
}
datasource db {
provider = "${provider}"
url = env("DATABASE_URL")
}
`
} else {
return `// This is your Prisma schema file,
return `// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
generator client {
Expand All @@ -47,7 +31,6 @@ datasource db {
url = env("DATABASE_URL")
}
`
}
}

export const defaultEnv = (
Expand All @@ -58,7 +41,7 @@ export const defaultEnv = (
? `# Environment variables declared in this file are automatically made available to Prisma.
# See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema
# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB (Preview) and CockroachDB (Preview).
# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB (Preview).
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings\n\n`
: ''
env += `DATABASE_URL="${url}"`
Expand Down Expand Up @@ -122,7 +105,7 @@ export class Init implements Command {
${chalk.bold('Options')}
-h, --help Display this help message
--datasource-provider Define the datasource provider to use: PostgreSQL, MySQL, SQLite, SQL Server or MongoDB (Preview)
--datasource-provider Define the datasource provider to use: PostgreSQL, MySQL, SQLite, SQL Server or MongoDB
--url Define a custom datasource url
${chalk.bold('Examples')}
Expand Down Expand Up @@ -295,7 +278,7 @@ export class Init implements Command {
'schema.prisma',
)} to match your database: ${chalk.green('postgresql')}, ${chalk.green('mysql')}, ${chalk.green(
'sqlite',
)}, ${chalk.green('sqlserver')} or ${chalk.green('mongodb')} (Preview).`,
)}, ${chalk.green('sqlserver')} or ${chalk.green('mongodb')}.`,
)
}

Expand Down
72 changes: 36 additions & 36 deletions packages/cli/src/__tests__/commands/Init.test.ts
Expand Up @@ -28,14 +28,14 @@ test('works with url param', async () => {

const env = fs.readFileSync(join(ctx.tmpDir, '.env'), 'utf-8')
expect(env).toMatchInlineSnapshot(`
# Environment variables declared in this file are automatically made available to Prisma.
# See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema
# Environment variables declared in this file are automatically made available to Prisma.
# See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema
# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB (Preview) and CockroachDB (Preview).
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings
# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB (Preview).
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings
DATABASE_URL="file:dev.db"
`)
DATABASE_URL="file:dev.db"
`)
})

test('works with provider param - postgresql', async () => {
Expand All @@ -48,14 +48,14 @@ test('works with provider param - postgresql', async () => {

const env = fs.readFileSync(join(ctx.tmpDir, '.env'), 'utf-8')
expect(env).toMatchInlineSnapshot(`
# Environment variables declared in this file are automatically made available to Prisma.
# See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema
# Environment variables declared in this file are automatically made available to Prisma.
# See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema
# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB (Preview) and CockroachDB (Preview).
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings
# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB (Preview).
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings
DATABASE_URL="postgresql://johndoe:randompassword@localhost:5432/mydb?schema=public"
`)
DATABASE_URL="postgresql://johndoe:randompassword@localhost:5432/mydb?schema=public"
`)
})

test('works with provider param - mysql', async () => {
Expand All @@ -68,14 +68,14 @@ test('works with provider param - mysql', async () => {

const env = fs.readFileSync(join(ctx.tmpDir, '.env'), 'utf-8')
expect(env).toMatchInlineSnapshot(`
# Environment variables declared in this file are automatically made available to Prisma.
# See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema
# Environment variables declared in this file are automatically made available to Prisma.
# See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema
# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB (Preview) and CockroachDB (Preview).
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings
# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB (Preview).
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings
DATABASE_URL="mysql://johndoe:randompassword@localhost:3306/mydb"
`)
DATABASE_URL="mysql://johndoe:randompassword@localhost:3306/mydb"
`)
})

test('works with provider param - SQLITE', async () => {
Expand All @@ -88,14 +88,14 @@ test('works with provider param - SQLITE', async () => {

const env = fs.readFileSync(join(ctx.tmpDir, '.env'), 'utf-8')
expect(env).toMatchInlineSnapshot(`
# Environment variables declared in this file are automatically made available to Prisma.
# See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema
# Environment variables declared in this file are automatically made available to Prisma.
# See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema
# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB (Preview) and CockroachDB (Preview).
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings
# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB (Preview).
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings
DATABASE_URL="file:./dev.db"
`)
DATABASE_URL="file:./dev.db"
`)
})

test('works with provider param - SqlServer', async () => {
Expand All @@ -108,14 +108,14 @@ test('works with provider param - SqlServer', async () => {

const env = fs.readFileSync(join(ctx.tmpDir, '.env'), 'utf-8')
expect(env).toMatchInlineSnapshot(`
# Environment variables declared in this file are automatically made available to Prisma.
# See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema
# Environment variables declared in this file are automatically made available to Prisma.
# See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema
# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB (Preview) and CockroachDB (Preview).
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings
# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB (Preview).
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings
DATABASE_URL="sqlserver://localhost:1433;database=mydb;user=SA;password=randompassword;"
`)
DATABASE_URL="sqlserver://localhost:1433;database=mydb;user=SA;password=randompassword;"
`)
})

test('works with provider param - MongoDB', async () => {
Expand All @@ -128,14 +128,14 @@ test('works with provider param - MongoDB', async () => {

const env = fs.readFileSync(join(ctx.tmpDir, '.env'), 'utf-8')
expect(env).toMatchInlineSnapshot(`
# Environment variables declared in this file are automatically made available to Prisma.
# See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema
# Environment variables declared in this file are automatically made available to Prisma.
# See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema
# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB (Preview) and CockroachDB (Preview).
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings
# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB (Preview).
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings
DATABASE_URL="mongodb+srv://root:randompassword@cluster0.ab1cd.mongodb.net/mydb?retryWrites=true&w=majority"
`)
DATABASE_URL="mongodb+srv://root:randompassword@cluster0.ab1cd.mongodb.net/mydb?retryWrites=true&w=majority"
`)
})

test('errors with invalid provider param', async () => {
Expand Down
Expand Up @@ -7,7 +7,7 @@ exports[`appends when .env present 1`] = `
Next steps:
1. Set the DATABASE_URL in the .env file to point to your existing database. If your database has no tables yet, read https://pris.ly/d/getting-started
2. Set the provider of the datasource block in schema.prisma to match your database: postgresql, mysql, sqlite, sqlserver or mongodb (Preview).
2. Set the provider of the datasource block in schema.prisma to match your database: postgresql, mysql, sqlite, sqlserver or mongodb.
3. Run prisma db pull to turn your database schema into a Prisma schema.
4. Run prisma generate to generate the Prisma Client. You can then start querying your database.
Expand All @@ -23,7 +23,7 @@ SOMTHING="is here"
# Environment variables declared in this file are automatically made available to Prisma.
# See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema
# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB (Preview) and CockroachDB (Preview).
# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB (Preview).
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings
DATABASE_URL="postgresql://johndoe:randompassword@localhost:5432/mydb?schema=public"
Expand All @@ -36,7 +36,7 @@ exports[`is schema and env written on disk replace 1`] = `
Next steps:
1. Set the DATABASE_URL in the .env file to point to your existing database. If your database has no tables yet, read https://pris.ly/d/getting-started
2. Set the provider of the datasource block in schema.prisma to match your database: postgresql, mysql, sqlite, sqlserver or mongodb (Preview).
2. Set the provider of the datasource block in schema.prisma to match your database: postgresql, mysql, sqlite, sqlserver or mongodb.
3. Run prisma db pull to turn your database schema into a Prisma schema.
4. Run prisma generate to generate the Prisma Client. You can then start querying your database.
Expand All @@ -54,7 +54,7 @@ warn Prisma would have added DATABASE_URL but it already exists in .env
Next steps:
1. Set the DATABASE_URL in the .env file to point to your existing database. If your database has no tables yet, read https://pris.ly/d/getting-started
2. Set the provider of the datasource block in schema.prisma to match your database: postgresql, mysql, sqlite, sqlserver or mongodb (Preview).
2. Set the provider of the datasource block in schema.prisma to match your database: postgresql, mysql, sqlite, sqlserver or mongodb.
3. Run prisma db pull to turn your database schema into a Prisma schema.
4. Run prisma generate to generate the Prisma Client. You can then start querying your database.
Expand Down
8 changes: 4 additions & 4 deletions packages/client/package.json
Expand Up @@ -63,10 +63,10 @@
"@opentelemetry/api": "1.0.3",
"@prisma/debug": "workspace:*",
"@prisma/engine-core": "workspace:*",
"@prisma/engines": "3.12.0-35.7e91d3111425c8915dcdd8e37bca69ddcb2c883d",
"@prisma/fetch-engine": "3.12.0-35.7e91d3111425c8915dcdd8e37bca69ddcb2c883d",
"@prisma/engines": "3.12.0-36.4c0f1c1c0d2a8371bb5d9c4d759305e171b5411a",
"@prisma/fetch-engine": "3.12.0-36.4c0f1c1c0d2a8371bb5d9c4d759305e171b5411a",
"@prisma/generator-helper": "workspace:*",
"@prisma/get-platform": "3.12.0-35.7e91d3111425c8915dcdd8e37bca69ddcb2c883d",
"@prisma/get-platform": "3.12.0-36.4c0f1c1c0d2a8371bb5d9c4d759305e171b5411a",
"@prisma/migrate": "workspace:*",
"@prisma/sdk": "workspace:*",
"@timsuchanek/copy": "1.4.5",
Expand Down Expand Up @@ -122,7 +122,7 @@
}
},
"dependencies": {
"@prisma/engines-version": "3.12.0-35.7e91d3111425c8915dcdd8e37bca69ddcb2c883d"
"@prisma/engines-version": "3.12.0-36.4c0f1c1c0d2a8371bb5d9c4d759305e171b5411a"
},
"sideEffects": false
}
4 changes: 1 addition & 3 deletions packages/client/src/__tests__/generation/generator.test.ts
Expand Up @@ -227,9 +227,7 @@ describe('generator', () => {
binaryTargets: Array [],
config: Object {},
name: client,
previewFeatures: Array [
mongoDb,
],
previewFeatures: Array [],
provider: Object {
fromEnvVar: null,
value: prisma-client-js,
Expand Down
1 change: 0 additions & 1 deletion packages/client/src/__tests__/generation/mongo.prisma
Expand Up @@ -5,7 +5,6 @@ datasource db {

generator client {
provider = "prisma-client-js"
previewFeatures = ["mongoDb"]
}

model User {
Expand Down
Expand Up @@ -5,7 +5,6 @@ datasource db {

generator client {
provider = "prisma-client-js"
previewFeatures = ["mongodb"]
}

model User {
Expand Down
Expand Up @@ -5,7 +5,6 @@ datasource db {

generator client {
provider = "prisma-client-js"
previewFeatures = ["mongodb"]
}

model CommentRequiredProp {
Expand Down
@@ -1,6 +1,5 @@
generator client {
provider = "prisma-client-js"
previewFeatures = ["mongodb"]
}

datasource db {
Expand Down
8 changes: 0 additions & 8 deletions packages/client/src/runtime/getPrismaClient.ts
Expand Up @@ -419,14 +419,6 @@ export function getPrismaClient(config: GetPrismaClientConfig) {
inlineSchemaHash: config.inlineSchemaHash,
}

// Append the mongodb experimental flag if the provider is mongodb
if (config.activeProvider === 'mongodb') {
const previewFeatures = this._engineConfig.previewFeatures
? this._engineConfig.previewFeatures.concat('mongodb')
: ['mongodb']
this._engineConfig.previewFeatures = previewFeatures
}

debug(`clientVersion: ${config.clientVersion}`)
debug(`clientEngineType: ${this._clientEngineType}`)

Expand Down
4 changes: 2 additions & 2 deletions packages/engine-core/package.json
Expand Up @@ -36,9 +36,9 @@
},
"dependencies": {
"@prisma/debug": "workspace:*",
"@prisma/engines": "3.12.0-35.7e91d3111425c8915dcdd8e37bca69ddcb2c883d",
"@prisma/engines": "3.12.0-36.4c0f1c1c0d2a8371bb5d9c4d759305e171b5411a",
"@prisma/generator-helper": "workspace:*",
"@prisma/get-platform": "3.12.0-35.7e91d3111425c8915dcdd8e37bca69ddcb2c883d",
"@prisma/get-platform": "3.12.0-36.4c0f1c1c0d2a8371bb5d9c4d759305e171b5411a",
"chalk": "4.1.2",
"execa": "5.1.1",
"get-stream": "6.0.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/migrate/package.json
Expand Up @@ -20,7 +20,7 @@
"version": "latest"
},
"devDependencies": {
"@prisma/engines-version": "3.12.0-35.7e91d3111425c8915dcdd8e37bca69ddcb2c883d",
"@prisma/engines-version": "3.12.0-36.4c0f1c1c0d2a8371bb5d9c4d759305e171b5411a",
"@prisma/generator-helper": "workspace:*",
"@prisma/sdk": "workspace:*",
"@swc/core": "1.2.141",
Expand All @@ -45,7 +45,7 @@
},
"dependencies": {
"@prisma/debug": "workspace:*",
"@prisma/get-platform": "3.12.0-35.7e91d3111425c8915dcdd8e37bca69ddcb2c883d",
"@prisma/get-platform": "3.12.0-36.4c0f1c1c0d2a8371bb5d9c4d759305e171b5411a",
"@sindresorhus/slugify": "1.1.2",
"chalk": "4.1.2",
"execa": "5.1.1",
Expand Down

0 comments on commit 401df2e

Please sign in to comment.