Elastic Beanstalk: how to reverse an RDS schema to a known state?

I am a bit confused about how to implement an Elastic Beanstalk based system that will allow me to drop both server code and RDS schema to a known good state in the event of a bad deployment.

I have an application that handles an up / up migration of the schema on every deployment (using .ebextensions/

). However, consider the following scenario:

  • Elastic Beanstalk runs version 1 of my application schema and databases.
  • I am pushing version 2 of my application, which migrates the RDS schema to version 2.
  • I redeploy version 1 of my app , however the RDS schema remains at version 2

I don't think I can drop migrations in step 3, because a back / down migration from version 2 does not exist at this point.

So what's the best way to approach this? Should I be using something like capistrano instead of deploying Elastic Beanstalk to get more control over the process?

+3


source to share


1 answer


As you might have guessed, there isn't a big, integrated mechanism for swapping schema changes in ElasticBeanstalk. For poor deployments, the best option is that transactions that change the schema will automatically rollback. In this case, you can simply fix the migration that went wrong and re-push it to EB.

If you're out of luck (for example, doing multiple migrations and failing halfway through) and need to manually migrate your schema, you can:

  • Specify a local application to use the RDS database (assuming you have a firewall installed to allow it) and migrate.


(or)

  • SSH into one of your EC2 instances and migrate from there.

I would be interested to know if there is a better automatic approach. However, when migrations fail (and you need to roll them back), you often have to fix them manually.

+2


source







All Articles