Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Database Migrations

Avatar for trumpi trumpi
September 08, 2012

Database Migrations

A synopsis of the different database migration methods that exist - both good and bad!

Avatar for trumpi

trumpi

September 08, 2012
Tweet

Other Decks in Programming

Transcript

  1. Backup the database in a dev environment – restore it

    in production The problem: Production data is completely overwritten by Dev data
  2. Script every change IF NOT EXISTS (…) Becomes a problem

    if a script undoes the changes of a previous script
  3. Write scripts that check a version table Add a row

    to the version table if the script is successful The best approach, but scripts are difficult to write Transactions are tricky Rolling back is difficult
  4. Library that provides an API for database changes Transactions and

    the version table is handled behind the scenes Provides forward and backward migration Libraries available in .NET • FluentMigrator • Migrator.NET
  5. Always back up the database before a migration Rather restore

    the database than run the “Down” migration