You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SQL Server: migrate dev (and db push) does not create a database #8058
This is the error message when you try to migrate a database that does not exist on SQL Server:
C:\Users\Jan\Documents\throwaway\sqlServerCycles>npx prisma migrate dev
Environment variables loaded from .env
Prisma schema loaded from prisma\schema.prisma
Datasource "db" - SQL Server
Error: Migration engine error:
Performing a TLS handshake
Trusting the server certificate without validation.
TLS handshake successful
Turning TLS off after a login. All traffic from here on is not encrypted.
Cannot open database "mydb" requested by the login. The login failed.
Database error
Database does not exist: mydb
(We should probably have tests for all databases that ensure this works)
changed the title [-]SQL Server: `migrate dev` does not create a database[/-][+]SQL Server: `migrate dev` (and `db push`) does not create a database[/+]on Jul 4, 2021
Error: Error: Migration engine error:
Performing a TLS handshake
Trusting the server certificate without validation.
TLS handshake successful
Turning TLS off after a login. All traffic from here on is not encrypted.
Cannot open database "hellomssql" requested by the login. The login failed.
Database error
Database does not exist: hellomssql
at Object.canConnectToDatabase (/Users/j42/Dev/prisma-esbuild/packages/sdk/dist/migrateEngineCommands.js:94:15)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at Object.ensureDatabaseExists (/Users/j42/Dev/prisma-esbuild/packages/migrate/src/utils/ensureDatabaseExists.ts:118:22)
at DbPush.parse (/Users/j42/Dev/prisma-esbuild/packages/migrate/src/commands/DbPush.ts:116:26)
at main (/Users/j42/Dev/prisma-esbuild/packages/migrate/src/bin.ts:80:18)
Just played with the CLI, needed to fix some logic but now I get this
In 2.29.0-dev.42 (and soon in 2.29)
First push env DEBUG="*" npx prisma@dev db push
Prisma schema loaded from prisma/schema.prisma
prisma:getConfig Using Query Engine Binary at: /Users/j42/.npm/_npx/35364/lib/node_modules/prisma/node_modules/@prisma/engines/query-engine-darwin +0ms
Datasource "my_db" - SQL Server
prisma:getConfig Using Query Engine Binary at: /Users/j42/.npm/_npx/35364/lib/node_modules/prisma/node_modules/@prisma/engines/query-engine-darwin +431ms
prisma:getConfig Using Query Engine Binary at: /Users/j42/.npm/_npx/35364/lib/node_modules/prisma/node_modules/@prisma/engines/query-engine-darwin +18ms
Error: Error: Migration engine error:
Performing a TLS handshake
Trusting the server certificate without validation.
TLS handshake successful
Turning TLS off after a login. All traffic from here on is not encrypted.
Database change from 'master' to 'master'
Changed database context to 'master'.
SQL collation change from None to windows-1252/windows-1252
Microsoft SQL Server version 4077846543
Packet size change from '4096' to '4096'
Starting a mssql connection.
Performing a TLS handshake
Trusting the server certificate without validation.
TLS handshake successful
Turning TLS off after a login. All traffic from here on is not encrypted.
Database change from 'sdfsd2' to 'master'
Changed database context to 'sdfsd2'.
SQL collation change from None to windows-1252/windows-1252
Microsoft SQL Server version 4077846543
Packet size change from '4096' to '4096'
Starting a mssql connection.
The specified schema name "dbo" either does not exist or you do not have permission to use it.
Database error
Error querying the database: 'The specified schema name "dbo" either does not exist or you do not have permission to use it.' on server 5af6d931d9fb executing on line 1 (code: 2760, state: 1, class: 16)
at createDatabase2 (/Users/j42/.npm/_npx/35364/lib/node_modules/prisma/build/index.js:43020:17)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async ensureDatabaseExists (/Users/j42/.npm/_npx/35364/lib/node_modules/prisma/build/index.js:64079:11)
at async _DbPush.parse (/Users/j42/.npm/_npx/35364/lib/node_modules/prisma/build/index.js:67446:28)
at async main (/Users/j42/.npm/_npx/35364/lib/node_modules/prisma/build/index.js:114233:18)
Second push env DEBUG="*" npx prisma@dev db push
Prisma schema loaded from prisma/schema.prisma
prisma:getConfig Using Query Engine Binary at: /Users/j42/.npm/_npx/36090/lib/node_modules/prisma/node_modules/@prisma/engines/query-engine-darwin +0ms
Datasource "my_db" - SQL Server
prisma:getConfig Using Query Engine Binary at: /Users/j42/.npm/_npx/36090/lib/node_modules/prisma/node_modules/@prisma/engines/query-engine-darwin +353ms
prisma:getConfig Using Query Engine Binary at: /Users/j42/.npm/_npx/36090/lib/node_modules/prisma/node_modules/@prisma/engines/query-engine-darwin +17ms
prisma:migrateEngine:rpc starting migration engine with binary: /Users/j42/.npm/_npx/36090/lib/node_modules/prisma/node_modules/@prisma/engines/migration-engine-darwin +0ms
prisma:migrateEngine:rpc SENDING RPC CALL {"id":1,"jsonrpc":"2.0","method":"schemaPush","params":{"force":false,"schema":"datasource my_db {\n provider = \"sqlserver\"\n url = \"sqlserver://localhost:1433;database=sdfsd2;user=SA;password=Pr1sm4_Pr1sm4;trustServerCertificate=true;\"\n}\n\n// datasource my_db {\n// provider = \"postgresql\"\n// url = \"postgres://prisma:prisma@localhost:5432/yoloooooooo\"\n// }\n\nmodel Blog {\n id Int @id\n viewCount20 Int\n}\n"}} +4ms
prisma:migrateEngine:stderr {"timestamp":"2021-08-10T08:58:37.523892+00:00","level":"INFO","fields":{"message":"Starting migration engine RPC server","git_hash":"36af3f44e00e1f6ae2ef08ebf105fb0120b43a66"},"target":"migration_engine"} +0ms
prisma:migrateEngine:stderr {"timestamp":"2021-08-10T08:58:37.529894+00:00","level":"INFO","fields":{"message":"Performing a TLS handshake"},"target":"tiberius::client::connection","span":{"name":"new_connection"},"spans":[{"name":"new_connection"}]} +6ms
prisma:migrateEngine:stderr {"timestamp":"2021-08-10T08:58:37.529930+00:00","level":"WARN","fields":{"message":"Trusting the server certificate without validation."},"target":"tiberius::client::connection","span":{"name":"new_connection"},"spans":[{"name":"new_connection"}]} +0ms
prisma:migrateEngine:stderr {"timestamp":"2021-08-10T08:58:37.548005+00:00","level":"INFO","fields":{"message":"TLS handshake successful"},"target":"tiberius::client::connection","span":{"name":"new_connection"},"spans":[{"name":"new_connection"}]} +18ms
prisma:migrateEngine:stderr {"timestamp":"2021-08-10T08:58:37.548102+00:00","level":"WARN","fields":{"message":"Turning TLS off after a login. All traffic from here on is not encrypted."},"target":"tiberius::client::connection","span":{"name":"new_connection"},"spans":[{"name":"new_connection"}]} +0ms
prisma:migrateEngine:stderr {"timestamp":"2021-08-10T08:58:37.554962+00:00","level":"INFO","fields":{"message":"Database change from 'sdfsd2' to 'master'"},"target":"tiberius::tds::stream::token","span":{"name":"new_connection"},"spans":[{"name":"new_connection"}]} +7ms
prisma:migrateEngine:stderr {"timestamp":"2021-08-10T08:58:37.554996+00:00","level":"INFO","fields":{"message":"Changed database context to 'sdfsd2'."},"target":"tiberius::tds::stream::token","span":{"name":"new_connection"},"spans":[{"name":"new_connection"}]} +0ms
prisma:migrateEngine:stderr {"timestamp":"2021-08-10T08:58:37.555011+00:00","level":"INFO","fields":{"message":"SQL collation change from None to windows-1252/windows-1252"},"target":"tiberius::tds::stream::token","span":{"name":"new_connection"},"spans":[{"name":"new_connection"}]} +0ms
prisma:migrateEngine:stderr {"timestamp":"2021-08-10T08:58:37.555025+00:00","level":"INFO","fields":{"message":"Microsoft SQL Server\u0000\u0000 version 4077846543"},"target":"tiberius::tds::stream::token","span":{"name":"new_connection"},"spans":[{"name":"new_connection"}]} +0ms
prisma:migrateEngine:stderr {"timestamp":"2021-08-10T08:58:37.555034+00:00","level":"INFO","fields":{"message":"Packet size change from '4096' to '4096'"},"target":"tiberius::tds::stream::token","span":{"name":"new_connection"},"spans":[{"name":"new_connection"}]} +0ms
prisma:migrateEngine:stderr {"timestamp":"2021-08-10T08:58:37.555078+00:00","level":"INFO","fields":{"message":"Starting a mssql connection."},"target":"quaint::single"} +0ms
🚀 Your database is now in sync with your schema. Done in 364ms
So something is created but we cannot use it right away somehow?
Activity
[-]SQL Server: `migrate dev` does not create a database[/-][+]SQL Server: `migrate dev` (and `db push`) does not create a database[/+]tomhoule commentedon Jul 5, 2021
@Jolg42 I think the new error logging code has a problem, this is not the expected error message. I'll try to look into this today.
tomhoule commentedon Jul 5, 2021
(looking into it currently)
fix(migrate): Print the expected error message on engine error
Jolg42 commentedon Jul 6, 2021
janpio commentedon Jul 6, 2021
7 remaining items
Jolg42 commentedon Aug 5, 2021
Error with
DEBUG="*"Jolg42 commentedon Aug 5, 2021
Should be fixed when prisma/prisma-engines#2133 drops
Jolg42 commentedon Aug 5, 2021
Jolg42 commentedon Aug 9, 2021
Just played with the CLI, needed to fix some logic but now I get this
In
2.29.0-dev.42(and soon in 2.29)First push
env DEBUG="*" npx prisma@dev db pushSecond push
env DEBUG="*" npx prisma@dev db pushSo something is created but we cannot use it right away somehow?
Jolg42 commentedon Aug 10, 2021
Note: the error on first "push" comes from calling
create-databasecommand on the engine.https://github.com/prisma/prisma/blob/fe3d63cc11678d756732ad14887eea62b2590c36/packages/sdk/src/migrateEngineCommands.ts#L249-L259
fix(migrate): sql server database creation if needed
fix(migrate): sql server database creation if needed (#8669)
Jolg42 commentedon Aug 10, 2021
Fixed in dev 2.29.0-dev.49 and will be part of 2.29.0 today.