We have a web application written using ASP.NET MVC, C # and MySQL and using Entity Framework 6 as ORM.
We use the Entity Framework CodeFirst Migrations to manage database changes over time and from release to release.
We have a continuous integration / deployment process created using Jenkins to create an assembly artifact (archive file) that loads into AWS S3, and from there the combination of the Lambda and AWS CodeDeploy functions is responsible for deploying the application for various EC2.
Each EF migration has both Up () and Down () methods that allow a specific migration file to update and lower the database for this particular version of the application code.
One thing that has recently appeared and for which we do not have a clear answer:
How do you manage database downgrades if you redeploy a previous version of your application?
Since the version of the application (and therefore the code) is older, any new EF migration files will not be included in it, therefore there are no Down () methods that can return your database to its previous state as Down () are all included in later EFs migrations, which are now no longer part of the application code (older version).
We don’t often go back to older versions of our application, but we can sometimes do this if we have unforeseen problems, and I’m sure that others had to deal with efficient rollback / downgrade of a database that was updated with a newer version of the application.
Does anyone have good strategies for working with database rollbacks / downgrades, ideally in the most automated way and, ideally, using the same previous build artifact for an older version (i.e. without the need to completely “rebuild” ) old version)?
c # continuous-integration entity-framework ef-migrations continuous-deployment
Bud goode
source share