Jonathan Locker
Jonathan Locker

Reputation: 21

Rolling back migrations in Clojure after Docker Container Rollback

We have a Clojure service that runs in a Docker Container running in Amazon ECS. When the container is deployed, the Clojure services connects to the database and always runs migrations on startup.

The problem is that if we need to rollback the code deploy, the deployed container has the old code in it, and does not have access to the rollback migrations that the latest container has.

This is a problem that doesn't happen often, but when it does, how do we perform the DB Rollback?

The best we can think of right now is to do it manually.

Anyone have experience doing this programatically?

Upvotes: 2

Views: 323

Answers (1)

Deadron
Deadron

Reputation: 5289

It seems like you should consider separating your migrations from your actual deployable. Everyone will have their own preference for managing migrations but you lose flexibility when you package your migrations into your application. A dedicated migration tool can act more intelligently when on its own. For example, some database migrations are impossible to rollback without some sort of snapshot system, ex any migration that removes data. Additionally, its bad practice for your application to have the permissions necessary to perform migrations. You also cannot easily audit which user performed the migration.

Upvotes: 2

Related Questions