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

Issue on docs: Migrations are not running in the Axum Postgres Todo App #212

Closed
albrow opened this issue Nov 1, 2023 · 0 comments · Fixed by #214 or shuttle-hq/shuttle-examples#110

Comments

@albrow
Copy link

albrow commented Nov 1, 2023

Path: /examples/axum-postgres

Following the instructions and sending a POST or GET request to the server results in the following error:

error returned from database: relation "todos" does not exist

I manually connected to the database via the psql CLI and I can see that the todos table was not created.

This is happening because the migration filename is not formatted correctly. The documentation for sqlx MigrationSource explains:

... a MigrationSource is a directory which contains the migration SQL scripts. All these scripts must be stored in files with names using the format _.sql, where is a string that can be parsed into i64 and its value is greater than zero, and is a string.

The solution is actually very simple. All you need to do is add the prefix 1_ to the filename. So rename ./migrations/schema.sql to ./migrations/1_schema.sql. After I applied this fix locally I was able to confirm that the todos table was created and everything worked as expected.

@albrow albrow changed the title Issue on docs Issue on docs: Migrations are not running in the Axum Postgres Todo App Nov 1, 2023
@jonaro00 jonaro00 linked a pull request Nov 2, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant