Skip to content

Migration fails creating new database on Managed DO Postgres #5742

@andyeskridge

Description

@andyeskridge

I'm looking to have prisma migration create some databases for me on a Managed Digital Ocean postgres instance. I have created a new user and made sure that the user has the ability to create databases. When I try to use that user with prisma migrate to create a new database, the execution fails with the attached error message below.

This seems to be the same issue that prisma/migrate#573 documents. The migrations work for me if the database already exists. The issue only appears when I try to have the prisma migration create a new database.

It looks like maybe one fix specific to Digital Ocean is to add defaultdb to: https://github.com/prisma/prisma-engines/blob/43e73b6d61a0d707a4b605daa6169624acc33b74/migration-engine/connectors/sql-migration-connector/src/flavour/postgres.rs#L337

{"is_panic":false,"message":"Database error: Error querying the database: db error: FATAL: pg_hba.conf rejects connection for host \"IP\", user \"USER\", database \"template1\", SSL on
   0: sql_migration_connector::flavour::postgres::create_database
          with self=PostgresFlavour { url: PostgresUrl { url: Url { scheme: \"postgresql\", host: Some(Domain(\"url.db.ondigitalocean.com\")), port: Some(12345), path: \"/new_db\", query: Some(\"sslmode=require\"), fragment: None }, query_params: PostgresUrlQueryParams { ssl_params: SslParams { certificate_file: None, identity_file: None, identity_password: <HIDDEN>, ssl_accept_mode: AcceptInvalidCerts }, connection_limit: None, schema: \"public\", ssl_mode: Require, pg_bouncer: false, host: None, socket_timeout: None, connect_timeout: Some(5s), pool_timeout: Some(5s), statement_cache_size: 500 } }, features: BitFlags<MigrationFeature>(0b0) }

prisma -v:

prisma               : 2.17.0
@prisma/client       : 2.17.0
Current platform     : windows
Query Engine         : query-engine 3c463ebd78b1d21d8fdacdd27899e280cf686223 (at node_modules\@prisma\engines\query-engine-windows.exe)
Migration Engine     : migration-engine-cli 3c463ebd78b1d21d8fdacdd27899e280cf686223 (at node_modules\@prisma\engines\migration-engine-windows.exe)
Introspection Engine : introspection-core 3c463ebd78b1d21d8fdacdd27899e280cf686223 (at node_modules\@prisma\engines\introspection-engine-windows.exe)
Format Binary        : prisma-fmt 3c463ebd78b1d21d8fdacdd27899e280cf686223 (at node_modules\@prisma\engines\prisma-fmt-windows.exe)
Studio               : 0.353.0

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions