Migration fails because the enum needs at least one row, but my data has rows?
See original GitHub issueI’m trying to migrate data from Heroku to Docker, following the guide from here https://docs.hasura.io/1.0/graphql/manual/migrations/existing-database.html.
This is what I get when I run hasura migrate apply --endpoint http://localhost:8080
:
FATA[0002] apply failed: [constraint-violation] the table "frequency" cannot be used as an enum because the table must have at least one row ($.args[2].args.tables[4])
Additional information:
- The table
frequency
doesn’t have zero rows, it actually has 10 rows, at least that’s what I see on the original Heroku db that I ranhasura migrate create
from. frequency
isn’t the only enum table, nor was it the first one that was created. I had another enum calledarchive_types
and this was created first and is alphabetically earlier thanfrequency
. This enum table also has values, but the console error doesn’t seem to mention it. Why would Hasura complain that that is something wrong withfrequency
but not witharchive_types
?- The only thing I did past
hasura migrate create "init"
was just create a test table, as stated in the guide.
Also I checked the files generated by the hasura migrate create "init"
command, and it only seems to contain data about the whole Graphql/postgres schema itself (both the yaml and sql file). It doesn’t even contain a single actual row, i.e. my test data. Is there a way to migrate the data themselves too? It seems like migration isn’t that useful if it can’t do this.
Issue Analytics
- State:
- Created 4 years ago
- Comments:17 (4 by maintainers)
@joshuarobs This should work (while we fix this with something better):
hasura migrate create "init" --from-server
pg_dump <postgres-url> --column-inserts --data-only -t frequency -t archive_types >> 15xxxx_init.sql
hasura migrate apply --endpoint prod-endpoint.com
You can add multiple -t flags for all the enum tables. Hope this helps!
this really needs a fix. It’s troublesome if you create the migration after making the enum tables or when refreshing the migration from scratch.