Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unhelpful error when the migrations table doesn't exist #737

Open
robacarp opened this issue Mar 4, 2022 · 1 comment
Open

Unhelpful error when the migrations table doesn't exist #737

robacarp opened this issue Mar 4, 2022 · 1 comment
Labels
improve error experience Make errors nicer to deal with

Comments

@robacarp
Copy link
Contributor

robacarp commented Mar 4, 2022

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.

@jwoertink jwoertink added the improve error experience Make errors nicer to deal with label Mar 4, 2022
@jwoertink
Copy link
Member

This should be handled similar to luckyframework/avram#737

@jwoertink jwoertink added the Hacktoberfest Valid Issue for Hacktoberfest label Oct 1, 2022
@jwoertink jwoertink removed the Hacktoberfest Valid Issue for Hacktoberfest label Nov 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improve error experience Make errors nicer to deal with
Projects
None yet
Development

No branches or pull requests

2 participants