Do you commit your changes to DB and Migrations in your Git Commits?

Viewed 309

I'm about to push a feature, which has a migration where I added a column to a table. and therefore changes to the DB, and both have been included in my last push. But now I'm unsure if they should be left out? If I was to leave either of those two files out, what would be the result for the feature being tested on someone elses machine?

1 Answers

You should commit both, the migration file and the schema. If someone tests your branch locally, they will be prompted to run the migration.Their local database tracks which migrations have run already and detects your migration as a new one. The schema file might be upated with a new timestamp (at the top of the file there is a timestamp).

If the reviewer of the PR doesn't change anything, he or she will just be able to discard the change of the timestamp change in the schema file or they can just delete the whole branch.

Related