hasura / graphql-engine

Blazing fast, instant realtime GraphQL APIs on your DB with fine grained access control, also trigger webhooks on database events.
https://hasura.io
Apache License 2.0
31.07k stars 2.76k forks source link

Delete table from Hasura console does not generate down migration #3376

Open brcol187 opened 4 years ago

brcol187 commented 4 years ago

Hello, dropping tables from "Hasura console" does not generate down migrations. I know raw SQL does not generate down migrations, but this happened to me by using the drop table button in the Hasura console.

Every other action seems to generate down migrations, it's only dropping tables that do not.

Is there a way to get Hasura to generate a down migration for this action? It is really important for my use case.

If this is not a bug and is intentional, is there a list of all actions that do not generate down migrations?

Thanks.

rikinsk commented 4 years ago

This is in a way intentional but far from ideal. As when we drop a table all its depended objects such as indexes, constraints, triggers, etc. get dropped as well it is quite hard to come up with an accurate down migration which would recreate all these objects.

That being said we should definitely try to do the best we can and display a Warning mentioning that the generated down migrations might not be 100% accurate.

marcopeg commented 4 years ago

It would be already something to have the table definition with constraints and indexes, then the developer can always fix the source code for tricky details.