We are developing web applications using ruby on rails.
Suppose I want to derive a topic branch from the master branch in git and develop in the topic branch
Suppose you created a user model in the topic branch
rails g model User rails db: migrate
If i were working on the topic branch at that time and you don't want to work on the topic branch
git stash git checkout master git stash drop
Even in such a case, if ralis db: migrate in the topic branch, it will be reflected in the database, and I think that it will affect the master branch as well.
(If i were working with vscode, even if you return to the master branch, the user migration file remains in the working directory)
Is there a way to avoid this, no matter what I do in the topic branch, it has no effect when I return to the master branch? Also, if there is something wrong with your own way (git stash, etc.), please teach me.
Answer # 1
Is there a way to avoid this, no matter what I do in the topic branch, it has no effect when I return to the master branch?
I don't think there is. So I think you have to adjust it yourself (humans use their heads carefully).
In this case,
git stashBefore you do
Roll back the migration file applied in the topic branch (
rails db: rollback)
That would be reasonable. Of course, for that, the migration file
downYou have to implement the method properly.
Also, when you roll back,
usersPlease note that the table will disappear (later)
git checkout topicHowever, the DB data does not come back).
Also, if there is something wrong with your own way (git stash, etc.), please teach me.
In this case, I don't think it's wrong (I can't say it unconditionally because I should use different commands depending on the purpose and the state of the working directory ...). The remaining migration files are annoying, so delete them (if you don't plan to use them anymore).
clean -fPlease also study.
- about git operation (branch) on vscode
- linux - about the background operation of the program
- python - about operation parameters in machine learning production
- about float type operation of c language
- mysql - about the database
- git i want to edit a commit that has been recorded in a remote branch in the past
- django - about database design
- about operation of git/github
- intellij git new branch creation is grayed out and cannot be newly created
- git push branch is explicitly prompted to set
- about git remote add origin/hoge when handling git from multiple pcs
- about if branch in nginx (lua)
- mysql - about database design
- postgresql - about db operation using flask and sqlalchemy
- database - about the advantages and disadvantages of db column division
- about communication use in gitlab
- deployment operation with git
- mysql - about production operation of application
- html - about ie operation with vba