Create and deploy a migration
We are at a stage where we've added some new functionality (comments endpoint) and some tests and we are ready to deploy the new feature to production. While implementing this new feature we created/modified quite a few files that define our database schema. As you can imagine, it would be hard to remember all those changes and pull them together in a single migration script, Luckily this is not how we do things around here.
Forgot all the changes you made and you want to take a quick look and review them? Try this.
subzero migrations add --dry-run dummy_migration
The output will show the sql statements that we'll need to run in order to have our production database schema match our development schema.
--dry-run parameter is quite useful, you can check with it if you've committed all your changes to a migration file.
Additionally, when you use it, you are also testing if all the migrations that you've created (but not deployed yet) can successfully be applied one after another.
Now let's do it for real.
subzero migrations add comments_model_and_endpoint
Commit the new migrations
git add db/migrations/
git commit -m "comments migrations"
All that's left to do now is deploy our new feature to production, and it's as simple as
git push (with
git tag before that)
git tag v1.1
git push --tags
Sit back and watch the magic happen.