lucky_cli
lucky_cli copied to clipboard
Unhelpful error when the migrations table doesn't exist
This is the error message when a user boots a new lucky app with a correctly configured database url which points to an empty database (no migrations table):
2022-03-04 20:01:41.619 UTC [68] ERROR: relation "migrations" does not exist at character 16
2022-03-04 20:01:41.619 UTC [68] STATEMENT: SELECT id FROM migrations WHERE version = $1
web | Unhandled exception: relation "migrations" does not exist (PQ::PQError)
web |
web |
web | 🎉 App running at http://127.0.0.1:3001
web |
web |
web | from lib/pg/src/pq/connection.cr:203:7 in 'handle_error'
web | from lib/pg/src/pq/connection.cr:186:7 in 'handle_async_frames'
web | from lib/pg/src/pq/connection.cr:162:7 in 'read'
web | from lib/pg/src/pq/connection.cr:157:7 in 'read'
web | from lib/pg/src/pq/connection.cr:414:31 in 'expect_frame'
web | from lib/pg/src/pq/connection.cr:413:5 in 'expect_frame'
web | from lib/pg/src/pg/statement.cr:18:5 in 'perform_query'
web | from lib/db/src/db/statement.cr:93:9 in 'perform_query_with_rescue'
web | from lib/db/src/db/statement.cr:80:7 in 'query:args'
web | from lib/db/src/db/pool_statement.cr:29:30 in 'query:args'
web | from lib/db/src/db/query_methods.cr:46:7 in 'query:args'
web | from lib/db/src/db/query_methods.cr:61:7 in 'query_one?:as'
web | from lib/avram/src/avram/migrator/migration.cr:67:7 in 'migrated?'
web | from lib/avram/src/avram/migrator/migration.cr:62:6 in 'pending?'
web | from lib/avram/src/avram/migrator/runner.cr:200:32 in 'pending_migrations'
web | from lib/avram/src/avram/migrator/runner.cr:172:9 in 'ensure_migrated!'
web | from src/start_server.cr:7:3 in '__crystal_main'
web | from /usr/share/crystal/src/crystal/main.cr:110:5 in 'main_user_code'
web | from /usr/share/crystal/src/crystal/main.cr:96:7 in 'main'
web | from /usr/share/crystal/src/crystal/main.cr:119:3 in 'main'
web | from __libc_start_main
web | from _start
web | from ???
As far as I can tell, that message comes from start_server.cr which is attempting to check to see that the database is up to date. Perhaps it should check to see if the migrations table exists before asking that question, and provide some helpful feedback if not.
This should be handled similar to https://github.com/luckyframework/avram/pull/737