Feedback on Hasura migrations
See original GitHub issueI tried migration as mentioned in hasura docs and ran in to some issues.
- I started creating tables from hasura dashboard with running
hasura console
. So migration files are not generated. I want to bring in the schema to migrations. I followed this guide to generate first migration https://docs.hasura.io/1.0/graphql/manual/migrations/database-with-migrations.html
When I tried to apply this migration on a new database, I got this error
Error: apply failed: [postgres-error] query execution failed ($.args[0].args)
File: ''
[42P06] FatalError: schema "public" already exists
I had to comment this line CREATE SCHEMA public;
from public-schema.sql which is generated with command pg_dump -O -x -h <db-host> -p <db-port> -U <db-user> -d <db-name> --schema public --schema-only > public-schema.sql
Commenting/removing CREATE SCHEMA public;
from public-schema.sql is not mentioned in the documentation.
- After generating first migration, I ran
hasura console
and started adding new columns from the hasura dashboard and migration are created automatically. Buthasura migrate apply
failed with error “table already exists”.hasura migrate status
results in
VERSION SOURCE STATUS DATABASE STATUS
1544721345907 Present Not Present
1544721838932 Not Present Present
1544721935023 Not Present Present
I think, first migration is not added in hdb_catalog.schema_migrations. Can you update docs about how to add first migration generated from existing database to schema_migrations
-
Currently new migration files are generated for each schema change. This could result in lot of migration file when the project is newly started. It would be better if there is an option to make few changes and save a single migration file for all these changes at once. For example: Create a table and add 20 columns of this table and save a migration file. (Currently system creates 21 migration files for this case)
-
Can you show
hdb_catalog.schema_migrations
table in hasura dashbaord. Useful when debugging issues with migrations -
Is it possible to rollback migations ? I couldn’t find docs related to rollback of migrations.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:13 (5 by maintainers)
I would like to rerun my migrations or at least a specific one. I can get the db sql migration to run by removing the entry inside of schema_migrations but I cannot get my metadata to run again. If I look at the hdb_metadata table it still has the older metadata instead of my new stuff. What do I do?
@shahidhk Thanks for the prompt response.
I am using the Postgres from docker file given by hasura.
Regarding 3: I am interested in consolidated migration files for better maintainability of code. If we have all schema changes related to a feature in one file, it will be easy to refer back in future