Users run into this issue if their database user has no privileges to create databases (MySQL / Postgres). This happens because Migrate tries to create a shadow database under the hood.
> DATABASE_URL="postgres://prismatest:prismatest@localhost:5432/prismatest" npx prisma migrate dev --preview-feature
Environment variables loaded from prisma/.env
Prisma schema loaded from prisma/schema.prisma
Datasource "db": PostgreSQL database "prismatest", schema "public" at "localhost:5432"
2020-12-08 17:22:21.346 WET [11179] ERROR: relation "_prisma_migrations" does not exist at character 126
2020-12-08 17:22:21.346 WET [11179] STATEMENT: SELECT "id", "checksum", "finished_at", "migration_name", "logs", "rolled_back_at", "started_at", "applied_steps_count" FROM "_prisma_migrations" ORDER BY "started_at" ASC
2020-12-08 17:22:21.347 WET [11179] ERROR: permission denied to create database
2020-12-08 17:22:21.347 WET [11179] STATEMENT: CREATE DATABASE "prisma_migrations_shadow_database_8e443e23-bb18-4c98-8903-8777da7f625b"
Error: A migration failed when applied to the shadow database:
Database error: Error querying the database: db error: ERROR: permission denied to create database
0: sql_migration_connector::flavour::postgres::sql_schema_from_migration_history
at migration-engine/connectors/sql-migration-connector/src/flavour/postgres.rs:172
1: sql_migration_connector::sql_database_migration_inferrer::calculate_drift
at migration-engine/connectors/sql-migration-connector/src/sql_database_migration_inferrer.rs:59
2: migration_core::api::DiagnoseMigrationHistory
at migration-engine/core/src/api.rs:148
Problem
Users run into this issue if their database user has no privileges to create databases (MySQL / Postgres). This happens because Migrate tries to create a shadow database under the hood.
Some of the situations where this might be the case:
Additional context