Lift migration fails with Postgres DB hosted on Heroku
See original GitHub issueI have a Postgres DB hosted on Heroku. This is my schema file:
datasource db {
provider = "postgresql"
url = "postgresql://xxxx@xxxx.eu-west-1.compute.amazonaws.com/xxxx?schema=my-schema"
}
model User {
id String @id @default(cuid())
name String?
email String @unique
}
When I try to save a migration using prisma2 lift save --name init
, the command takes 1-2 minutes and then fails. This is the DEBUG
output:
$ prisma2 lift save --name init
LiftEngine:rpc SENDING RPC CALL {
id: 1,
jsonrpc: '2.0',
method: 'listMigrations',
params: {
projectInfo: '',
sourceConfig: 'datasource db {\n provider = "postgresql"\n url = ' +
'"postgresql://opnmyfngbknppm:xxxx@xxxxx.eu-west-1.compute.amazonaws.com/xxxx?schema=my-schema"\n' +
'}\n\nmodel User {\n id String @id @default(cuid())\n name ' +
'String?\n email String @unique\n}'
}
} +0ms
LiftEngine:stderr [migration-engine/connectors/sql-migration-connector/src/lib.rs:267] format!("CREATE SCHEMA IF NOT EXISTS \"{}\";" , & self . schema_name) = "CREATE SCHEMA IF NOT EXISTS \"my-schema\";"
LiftEngine:stderr +0ms
LiftEngine SqlMigrationPersistence.init() +0ms
LiftEngine:stderr [migration-engine/connectors/sql-migration-connector/src/sql_migration_persistence.rs:38] m.make_from(barrel_variant) = "CREATE TABLE \"my-schema\".\"_Migration\" (\"revision\" SERIAL PRIMARY KEY NOT NULL, \"name\" TEXT NOT NULL, \ +115ms
LiftEngine:stderr "datamodel\" TEXT NOT NULL, \"status\" TEXT NOT NULL, \"applied\" INTEGER NOT NULL, \"rolled_back\" INTEGER NOT NULL, \"datamodel_steps\" TEXT NOT NULL, \"database_migration\" TEXT NOT NULL, \"errors\" TEXT NOT NULL, \"started_at\" timestamp(3) NOT NULL, \"finished_at\" timestamp(3));"
LiftEngine:stderr +0ms
LiftEngine ListMigrationStepsInput { source_config: "datasource db {\n provider = \"postgresql\"\n url = \"postgresql://xxx:xxxx@ec2-46-137-91-216.eu-west-1.compute.xxx.com/xxxx?schema=my-schema\"\n}\n\nmodel User {\n id String @id @default(cuid())\n name String?\n email String @unique\n}" } +117ms
LiftEngine:stderr thread 'main' panicked at 'Connecting to Postgres failed: ConnectionError(Error(Some("db error: FATAL: too many connections for role \"xxxxx\""))
LiftEngine:stderr
LiftEngine:stderr stack backtrace:
LiftEngine:stderr 0: backtrace::backtrace::trace::h5511721bea6fa8d5 (0x1032e806e)
LiftEngine:stderr 1: backtrace::capture::Backtrace::new_unresolved::h28f9c9663a9420c8 (0x1032e71c8)
LiftEngine:stderr 2: failure::backtrace::internal::InternalBacktrace::new::hbb41405b6d19ab81 (0x1032e6b69)
LiftEngine:stderr 3: <failure::backtrace::Backtrace as core::default::Default>::default::h0458ad281d4247c8 (0x1032e6d55)
LiftEngine:stderr 4: prisma_query::connector::postgres::PostgreSql::new::he3139660a0f6e159 (0x102e002cb)
LiftEngine:stderr 5: sql_migration_connector::SqlMigrationConnector::postgres_helper::h6b4e2e3c1c2c1393 (0x102d3013a)
LiftEngine:stderr 6: sql_migration_connector::SqlMigrationConnector::exists::hc96a4351ceb42a7f (0x102d2f113)
LiftEngine:stderr 7: migration_core::connector_loader::load_connector::he9b6c98023b5fe33 (0x102c725fd)
LiftEngine:stderr 8: <migration_core::commands::list_migrations::ListMigrationStepsCommand as migration_core::commands::command::MigrationCommand>::execute::h4681dfb71054f617 (0x102c6ce5a)
LiftEngine:stderr 9: <F as jsonrpc_core::calls::RpcMethodSimple>::call::h731276293826fe71 (0x102cb0b71)
LiftEngine:stderr 10: <F as jsonrpc_core::calls::RpcMethod<T>>::call::h0bccd4ccb2209bab (0x102c5c4ac)
LiftEngine:stderr 11: <futures::future::lazy::Lazy<F,R> as futures::future::Future>::poll::hbce6018d6b2a48cd (0x102c6f802)
LiftEngine:stderr 12: <futures::future::then::Then<A,B,F> as futures::future::Future>::poll::ha20f1741903c245e (0x102c5cde0)
LiftEngine:stderr 13: <futures::future::map::Map<A,F> as futures::future::Future>::poll::haae0bf8700c0eb32 (0x102c78dff)
LiftEngine:stderr 14: <futures::future::either::Either<A,B> as futures::future::Future>::poll::h4a4aca43b1ee3dea (0x102c6fb10)
LiftEngine:stderr 15: futures::task_impl::std::set::h382d2f989081b561 (0x102ca7a0f)
LiftEngine:stderr 16: std::thread::local::LocalKey<T>::with::h5dad55bb9a34777a (0x102cab636)
LiftEngine:stderr 17: futures::future::Future::wait::h745e9887fa88aa85 (0x102c78c4f)
LiftEngine:stderr 18: jsonrpc_core::io::IoHandler<M>::handle_request_sync::h0cb26aa56e980a1c (0x102c570ff)
LiftEngine:stderr 19: migration_core::rpc_api::RpcApi::handle::h79a39cc857542478 (0x102cb7bab)
LiftEngine:stderr 20: migration_engine::main::h7042bfc8e66af2e4 (0x102c339bd)
LiftEngine:stderr 21: std::rt::lang_start::{{closure}}::hebcb40d09a9c307b (0x102c33a26)
LiftEngine:stderr 22: std::panicking::try::do_call::h1252fc9a2ff235eb (0x10330d4a8)
LiftEngine:stderr 23: __rust_maybe_catch_panic (0x10331188f)
LiftEngine:stderr 24: std::rt::lang_start_internal::h4c054360e442146c (0x10330df8e)
LiftEngine:stderr 25: main (0x102c33a19))', src/libcore/result.rs:997:5
LiftEngine:stderr +2m
LiftEngine:stderr stack backtrace:
LiftEngine:stderr +20ms
LiftEngine:stderr 0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
LiftEngine:stderr 1: std::sys_common::backtrace::_print
LiftEngine:stderr 2: std::panicking::default_hook::{{closure}}
LiftEngine:stderr +0ms
LiftEngine:stderr 3: std::panicking::default_hook
LiftEngine:stderr 4: +0ms
LiftEngine:stderr std::panicking::rust_panic_with_hook
LiftEngine:stderr 5: std::panicking::continue_panic_fmt
LiftEngine:stderr +0ms
LiftEngine:stderr 6: rust_begin_unwind
LiftEngine:stderr +0ms
LiftEngine:stderr 7: core::panicking::panic_fmt
LiftEngine:stderr +0ms
LiftEngine:stderr 8: core::result::unwrap_failed
LiftEngine:stderr 9: sql_migration_connector::SqlMigrationConnector::postgres_helper
LiftEngine:stderr 10: sql_migration_connector::SqlMigrationConnector::exists
LiftEngine:stderr 11: migration_core::connector_loader::load_connector
LiftEngine:stderr 12: <migration_core::commands::list_migrations::ListMigrationStepsCommand as migration_core::commands::command::MigrationCommand>::execute
LiftEngine:stderr 13: <F as jsonrpc_core::calls::RpcMethodSimple>::call
LiftEngine:stderr 14: <F as jsonrpc_core::calls::RpcMethod<T>>::call
LiftEngine:stderr 15: <futures::future::lazy::Lazy<F,R +1ms
LiftEngine:stderr > as futures::future::Future>::poll
LiftEngine:stderr 16: <futures::future::then::Then<A,B,F> as futures::future::Future>::poll
LiftEngine:stderr 17: <futures::future::map::Map<A,F> as futures::future +0ms
LiftEngine:stderr ::Future>::poll
LiftEngine:stderr 18: <futures::future::either::Either<A,B> as futures::future::Future>::poll
LiftEngine:stderr 19: futures::task_impl::std::set
LiftEngine:stderr 20: std::thread::local::LocalKey<T>::with
LiftEngine:stderr 21: futures::future::Future::wait
LiftEngine:stderr 22: jsonrpc_core::io::IoHandler<M>::handle_request_sync
LiftEngine:stderr 23: migration_core::rpc_api::RpcApi::handle
LiftEngine:stderr 24: migration_engine::main
LiftEngine:stderr 25: std::rt::lang_start::{{closure}}
LiftEngine:stderr 26: std::panicking::try::do_call
LiftEngine:stderr 27: __rust_maybe_catch_panic
LiftEngine:stderr 28: std::rt::lang_start_internal
LiftEngine:stderr 29: main
LiftEngine:stderr +2ms
Error: Error: Error in lift engine for rpc listMigrations:
[migration-engine/connectors/sql-migration-connector/src/lib.rs:267] format!("CREATE SCHEMA IF NOT EXISTS \"{}\";" , & self . schema_name) = "CREATE SCHEMA IF NOT EXISTS \"my-schema\";"
[migration-engine/connectors/sql-migration-connector/src/sql_migration_persistence.rs:38] m.make_from(barrel_variant) = "CREATE TABLE \"my-schema\".\"_Migration\" (\"revision\" SERIAL PRIMARY KEY NOT NULL, \"name\" TEXT NOT NULL, \"datamodel\" TEXT NOT NULL, \"status\" TEXT NOT NULL, \"applied\" INTEGER NOT NULL, \"rolled_back\" INTEGER NOT NULL, \"datamodel_steps\" TEXT NOT NULL, \"database_migration\" TEXT NOT NULL, \"errors\" TEXT NOT NULL, \"started_at\" timestamp(3) NOT NULL, \"finished_at\" timestamp(3));"
thread 'main' panicked at 'Connecting to Postgres failed: ConnectionError(Error(Some("db error: FATAL: too many connections for role \"xxxx\""))
stack backtrace:
0: backtrace::backtrace::trace::h5511721bea6fa8d5 (0x1032e806e)
1: backtrace::capture::Backtrace::new_unresolved::h28f9c9663a9420c8 (0x1032e71c8)
2: failure::backtrace::internal::InternalBacktrace::new::hbb41405b6d19ab81 (0x1032e6b69)
3: <failure::backtrace::Backtrace as core::default::Default>::default::h0458ad281d4247c8 (0x1032e6d55)
4: prisma_query::connector::postgres::PostgreSql::new::he3139660a0f6e159 (0x102e002cb)
5: sql_migration_connector::SqlMigrationConnector::postgres_helper::h6b4e2e3c1c2c1393 (0x102d3013a)
6: sql_migration_connector::SqlMigrationConnector::exists::hc96a4351ceb42a7f (0x102d2f113)
7: migration_core::connector_loader::load_connector::he9b6c98023b5fe33 (0x102c725fd)
8: <migration_core::commands::list_migrations::ListMigrationStepsCommand as migration_core::commands::command::MigrationCommand>::execute::h4681dfb71054f617 (0x102c6ce5a)
9: <F as jsonrpc_core::calls::RpcMethodSimple>::call::h731276293826fe71 (0x102cb0b71)
10: <F as jsonrpc_core::calls::RpcMethod<T>>::call::h0bccd4ccb2209bab (0x102c5c4ac)
11: <futures::future::lazy::Lazy<F,R> as futures::future::Future>::poll::hbce6018d6b2a48cd (0x102c6f802)
12: <futures::future::then::Then<A,B,F> as futures::future::Future>::poll::ha20f1741903c245e (0x102c5cde0)
13: <futures::future::map::Map<A,F> as futures::future::Future>::poll::haae0bf8700c0eb32 (0x102c78dff)
14: <futures::future::either::Either<A,B> as futures::future::Future>::poll::h4a4aca43b1ee3dea (0x102c6fb10)
15: futures::task_impl::std::set::h382d2f989081b561 (0x102ca7a0f)
16: std::thread::local::LocalKey<T>::with::h5dad55bb9a34777a (0x102cab636)
17: futures::future::Future::wait::h745e9887fa88aa85 (0x102c78c4f)
18: jsonrpc_core::io::IoHandler<M>::handle_request_sync::h0cb26aa56e980a1c (0x102c570ff)
19: migration_core::rpc_api::RpcApi::handle::h79a39cc857542478 (0x102cb7bab)
20: migration_engine::main::h7042bfc8e66af2e4 (0x102c339bd)
21: std::rt::lang_start::{{closure}}::hebcb40d09a9c307b (0x102c33a26)
22: std::panicking::try::do_call::h1252fc9a2ff235eb (0x10330d4a8)
23: __rust_maybe_catch_panic (0x10331188f)
24: std::rt::lang_start_internal::h4c054360e442146c (0x10330df8e)
25: main (0x102c33a19))', src/libcore/result.rs:997:5
stack backtrace:
0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
1: std::sys_common::backtrace::_print
2: std::panicking::default_hook::{{closure}}
3: std::panicking::default_hook
4: std::panicking::rust_panic_with_hook
5: std::panicking::continue_panic_fmt
6: rust_begin_unwind
7: core::panicking::panic_fmt
8: core::result::unwrap_failed
9: sql_migration_connector::SqlMigrationConnector::postgres_helper
10: sql_migration_connector::SqlMigrationConnector::exists
11: migration_core::connector_loader::load_connector
12: <migration_core::commands::list_migrations::ListMigrationStepsCommand as migration_core::commands::command::MigrationCommand>::execute
13: <F as jsonrpc_core::calls::RpcMethodSimple>::call
14: <F as jsonrpc_core::calls::RpcMethod<T>>::call
15: <futures::future::lazy::Lazy<F,R> as futures::future::Future>::poll
16: <futures::future::then::Then<A,B,F> as futures::future::Future>::poll
17: <futures::future::map::Map<A,F> as futures::future::Future>::poll
18: <futures::future::either::Either<A,B> as futures::future::Future>::poll
19: futures::task_impl::std::set
20: std::thread::local::LocalKey<T>::with
21: futures::future::Future::wait
22: jsonrpc_core::io::IoHandler<M>::handle_request_sync
23: migration_core::rpc_api::RpcApi::handle
24: migration_engine::main
25: std::rt::lang_start::{{closure}}
26: std::panicking::try::do_call
27: __rust_maybe_catch_panic
28: std::rt::lang_start_internal
29: main
at ChildProcess.<anonymous> (/Users/nikolasburk/.config/yarn/global/node_modules/prisma2/build/index.js:106392:28)
at ChildProcess.emit (events.js:196:13)
at Process.ChildProcess._handle.onexit (internal/child_process.js:257:12)
After the failed migration, there was this file generated: failed-listMigrations-20190703102646.md
. Here are the contents:
Failed listMigrations at 2019-07-03T08:26:46.778Z
RPC Input One Line
{"id":1,"jsonrpc":"2.0","method":"listMigrations","params":{"projectInfo":"","sourceConfig":"datasource db {\n provider = \"postgresql\"\n url = \"postgresql://xxxx@ec2-46-137-91-xxx.eu-west-1.compute.amazonaws.com/xxx?schema=my-schema\"\n}\n\nmodel User {\n id String @id @default(cuid())\n name String?\n email String @unique\n}"}}
RPC Input Readable
{
"id": 1,
"jsonrpc": "2.0",
"method": "listMigrations",
"params": {
"projectInfo": "",
"sourceConfig": "datasource db {\n provider = \"postgresql\"\n url = \"postgresql://xxxx@xxxx.eu-west-1.compute.amazonaws.com/xxxx?schema=my-schema\"\n}\n\nmodel User {\n id String @id @default(cuid())\n name String?\n email String @unique\n}"
}
}
RPC Response
null
Stack Trace
[migration-engine/connectors/sql-migration-connector/src/lib.rs:267] format!("CREATE SCHEMA IF NOT EXISTS \"{}\";" , & self . schema_name) = "CREATE SCHEMA IF NOT EXISTS \"my-schema\";"
[migration-engine/connectors/sql-migration-connector/src/sql_migration_persistence.rs:38] m.make_from(barrel_variant) = "CREATE TABLE \"my-schema\".\"_Migration\" (\"revision\" SERIAL PRIMARY KEY NOT NULL, \"name\" TEXT NOT NULL, \"datamodel\" TEXT NOT NULL, \"status\" TEXT NOT NULL, \"applied\" INTEGER NOT NULL, \"rolled_back\" INTEGER NOT NULL, \"datamodel_steps\" TEXT NOT NULL, \"database_migration\" TEXT NOT NULL, \"errors\" TEXT NOT NULL, \"started_at\" timestamp(3) NOT NULL, \"finished_at\" timestamp(3));"
thread 'main' panicked at 'Connecting to Postgres failed: ConnectionError(Error(Some("db error: FATAL: too many connections for role \"opnmyfngbknppm\""))
stack backtrace:
0: backtrace::backtrace::trace::h5511721bea6fa8d5 (0x1032e806e)
1: backtrace::capture::Backtrace::new_unresolved::h28f9c9663a9420c8 (0x1032e71c8)
2: failure::backtrace::internal::InternalBacktrace::new::hbb41405b6d19ab81 (0x1032e6b69)
3: <failure::backtrace::Backtrace as core::default::Default>::default::h0458ad281d4247c8 (0x1032e6d55)
4: prisma_query::connector::postgres::PostgreSql::new::he3139660a0f6e159 (0x102e002cb)
5: sql_migration_connector::SqlMigrationConnector::postgres_helper::h6b4e2e3c1c2c1393 (0x102d3013a)
6: sql_migration_connector::SqlMigrationConnector::exists::hc96a4351ceb42a7f (0x102d2f113)
7: migration_core::connector_loader::load_connector::he9b6c98023b5fe33 (0x102c725fd)
8: <migration_core::commands::list_migrations::ListMigrationStepsCommand as migration_core::commands::command::MigrationCommand>::execute::h4681dfb71054f617 (0x102c6ce5a)
9: <F as jsonrpc_core::calls::RpcMethodSimple>::call::h731276293826fe71 (0x102cb0b71)
10: <F as jsonrpc_core::calls::RpcMethod<T>>::call::h0bccd4ccb2209bab (0x102c5c4ac)
11: <futures::future::lazy::Lazy<F,R> as futures::future::Future>::poll::hbce6018d6b2a48cd (0x102c6f802)
12: <futures::future::then::Then<A,B,F> as futures::future::Future>::poll::ha20f1741903c245e (0x102c5cde0)
13: <futures::future::map::Map<A,F> as futures::future::Future>::poll::haae0bf8700c0eb32 (0x102c78dff)
14: <futures::future::either::Either<A,B> as futures::future::Future>::poll::h4a4aca43b1ee3dea (0x102c6fb10)
15: futures::task_impl::std::set::h382d2f989081b561 (0x102ca7a0f)
16: std::thread::local::LocalKey<T>::with::h5dad55bb9a34777a (0x102cab636)
17: futures::future::Future::wait::h745e9887fa88aa85 (0x102c78c4f)
18: jsonrpc_core::io::IoHandler<M>::handle_request_sync::h0cb26aa56e980a1c (0x102c570ff)
19: migration_core::rpc_api::RpcApi::handle::h79a39cc857542478 (0x102cb7bab)
20: migration_engine::main::h7042bfc8e66af2e4 (0x102c339bd)
21: std::rt::lang_start::{{closure}}::hebcb40d09a9c307b (0x102c33a26)
22: std::panicking::try::do_call::h1252fc9a2ff235eb (0x10330d4a8)
23: __rust_maybe_catch_panic (0x10331188f)
24: std::rt::lang_start_internal::h4c054360e442146c (0x10330df8e)
25: main (0x102c33a19))', src/libcore/result.rs:997:5
stack backtrace:
0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
1: std::sys_common::backtrace::_print
2: std::panicking::default_hook::{{closure}}
3: std::panicking::default_hook
4: std::panicking::rust_panic_with_hook
5: std::panicking::continue_panic_fmt
6: rust_begin_unwind
7: core::panicking::panic_fmt
8: core::result::unwrap_failed
9: sql_migration_connector::SqlMigrationConnector::postgres_helper
10: sql_migration_connector::SqlMigrationConnector::exists
11: migration_core::connector_loader::load_connector
12: <migration_core::commands::list_migrations::ListMigrationStepsCommand as migration_core::commands::command::MigrationCommand>::execute
13: <F as jsonrpc_core::calls::RpcMethodSimple>::call
14: <F as jsonrpc_core::calls::RpcMethod<T>>::call
15: <futures::future::lazy::Lazy<F,R> as futures::future::Future>::poll
16: <futures::future::then::Then<A,B,F> as futures::future::Future>::poll
17: <futures::future::map::Map<A,F> as futures::future::Future>::poll
18: <futures::future::either::Either<A,B> as futures::future::Future>::poll
19: futures::task_impl::std::set
20: std::thread::local::LocalKey<T>::with
21: futures::future::Future::wait
22: jsonrpc_core::io::IoHandler<M>::handle_request_sync
23: migration_core::rpc_api::RpcApi::handle
24: migration_engine::main
25: std::rt::lang_start::{{closure}}
26: std::panicking::try::do_call
27: __rust_maybe_catch_panic
28: std::rt::lang_start_internal
29: main
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Migrating Heroku Postgres Databases to Private Spaces
Migration guide for moving a currently active Heroku Postgres database into a Heroku Private Space.
Read more >ruby on rails - Migrate not working on Heroku - Stack Overflow
The problem comes from this issue: https://github.com/rails/rails/issues/21226 the command cannot be run correctly. If you need to do a db:structure load ...
Read more >Create a Web App and Deploy it to the Cloud in 20 minutes ...
Complete guide for beginner developers to create a web app, connect to a Postgres database, and deploy the app and database to the...
Read more >Migrating Large Heroku Postgres Instances to AWS Aurora ...
Be sure to update `randonumba.settings.ALLOWED_HOSTS` to include the host that Heroku provides. 3) Push the App Code to Heroku git push heroku ......
Read more >heroku postgres sql changes not reflected in db [closed]
You're never committing your transaction. Add connection.commit() before you call cursor.close() . Docs here.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
Top Related Hashnode Post
No results found
@matthewmueller just fyi, the edit history is still public on github, so be wary of that
Fixed in https://github.com/prisma/prisma2/releases/tag/2.0.0-preview-3.1