Skip to content
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

How to migrate db #7

Open
kayhide opened this issue Aug 4, 2022 · 1 comment
Open

How to migrate db #7

kayhide opened this issue Aug 4, 2022 · 1 comment

Comments

@kayhide
Copy link
Contributor

kayhide commented Aug 4, 2022

We need to think about how to migrate our db.
Usually, the schema of db evolves as development proceed and we need to update it consistently on production environment.

@kayhide
Copy link
Contributor Author

kayhide commented Aug 4, 2022

As a reference, here is the case of rails.

On rails, we create one "migration" file for every update on db schema.
"migration" files typically contain directives for creating table, adding/removing columns, adding/removing indices, updating column attributes like default values or null abilities...
And they often also contain a code to update records related to schema update, like populating new columns.

"migration" files are ordered based on timestamp and supposed to be executed in that order.
Db holds a "migrations" table to record which "migration" is executed.
When a developer (or a CI) executes migration, rails sees the migrations table in the db and executes ones which are not executed yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant