-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
cli: add command to reset migrations #5373
Comments
I agree that this would be a good addition as my feature development workflow has lots of writing |
@scriptonist I like to work on this |
@tharun208 you can go ahead, good luck! 😁 Edit: I've assigned this task to you as well. |
Hi @tharun208! Wanted to check in if you need any help. Also, could you please open a draft PR with your progress? |
I would like to work on this |
Haven't heard from @tharun208 in while so I think it's okay for you pick it up @sushil97 |
@scriptonist i would love to work on this but right now i am working on another PR. So there will be some delays on this. |
Hi, I have just upgraded my hasura engine and CLI to hasura version
INFO hasura cli version=v2.0.0-alpha.9
INFO hasura graphql engine endpoint="http://localhost:8001/" version=v2.0.0-alpha.9 And I discovered that resetting the migration history on the server is still under construction. Moreover I noticed that you cannot do any more TRUNCATE hdb_catalog.schema_migrations; And if you pull the schema and metadata from the server, you will loose the granularity of having multiple migration steps, i.e. So after restoring my PostgreSQL database, I initialised metadata operations and migrations folder and copied schema migrations from a backup folder. hasura migrate status --database-name default
VERSION NAME SOURCE STATUS DATABASE STATUS
1615111441648 Schema_auth Present Not Present
1615197558676 Account Present Not Present
1615261416207 AccountConfirmation Present Not Present
etc... Now the trick is to mark ALL migration steps as applied by skipping execution and make them present in the database. That can be done easily by running the following pipeline (check how many line you need to skip NR>?): hasura migrate status --database-name default | awk 'NR>2 {print $1}' | xargs -I{} sh -c 'hasura migrate apply --version {} --skip-execution --database-name default' Anyway hope that helps others that have the same problem until hasura team implements migrations reset with a more efficient and elegant solution. |
hasura migrate reset
This command should clear the history of the migrations on the server and clear the local migrations. Basically, do steps 1 and 2 mentioned in this blog post: https://hasura.io/blog/resetting-hasura-migrations/
The text was updated successfully, but these errors were encountered: