-
Notifications
You must be signed in to change notification settings - Fork 0
Good DX for git #9
Comments
Please checkout version It enables the following:
There are possibilities of bugs. So, do let me know. Git checkouts worked fine for me even on repeated attempts. Attached screenshot below. Git pull worked fine on initial carousal look. Attached Screenshot below. |
I ran into an issue where the Hasura CLI does not seem to work correctly. I made a video here: |
Another corner case:
|
This is a race condition. Here 's my solution: I will let environment become active again after If the user pulled code BEFORE the environment performed the migrations (i.e. during health check stage) it was supposed to, then Hasura CLI will apply the migrations that came AFTER pull. And if the user pulled AFTER the env had already performed it's migrations, and Hasura CLI won't re-apply the same migrations, even if we run As complex as this solution sounds to be implemented from my end, it's equally complex for the user. Because it can break the user's own migrations. If we applied newly pulled migrations BEFORE the original migrations of the "new" branch after checkout. |
@elitan The Hasura Console <> Hasura CLI issue should be solved in Heads up! Nhost CLI will no longer re-launch Hasura console and Mailhog tabs in your browser just because you did I've also implemented the aforementioned solution for the race condition problem. I'm yet to test that solution, though! Will work more on it tonight. |
I guess we can close this issue for now? The CLI works as intended for git branch changes and git pull |
Git branches
Postgres / Hasura does not play well with different git branches out of the box.
Imagine the following:
nhost dev
In step 7 when the developer goes back to main from new branch the database still has the changes from new branch. If the developer after step 8 does any change in Hasura, the Hasura CLI will save the metadata changes that were created in new branch.
Ideally, every git branch should have its own isolated database and the developer should seemingly be able to checkout different branches and the CLI should make sure that the database is up-to-date with whatever branch the developer is at.
Proposed solution
The CLI keeps track of the active branch and creates a separate folder inside
.nhost
for each branch. Ex:And whenever the developer switch branch the CLI should:
Git pull
Imagine a developer work locally in the
main
branch and havenhost dev
running. They then dogit pull
and their co-workers have updated some migrations and metadata. After thegit pull
the developer's postgres/hasura is out of sync. Aftergit pull
the developer has to runhasura migrate apply
andhasura metadata apply
to get their postgres/hasura in sync again.This is however easy to forget.
Ideally the CLI should keep track of this and apply these migrations and metadata changes automatically after a
git pull
to make sure that the code (migrations/metadata) and the database/api (postgres/hasura) are always in sync.Possibly solution
CLI should run
hasura migrate apply
andhasura metadata apply
automatically aftergit pull
. Possibly by keeping internal information about thegit log
and runapply
commands when the current commit changes.The text was updated successfully, but these errors were encountered: