Intro to Database Migration - raisercostin/software-wiki GitHub Wiki

Database refactoring steps

  • Every refactoring step should be reversible or with low cost of failure. This can be achieved if the Open Closed Principle Principles is respected: the database is open for extensions (adding tables, columns) and closed for modifications (renaming and deleting tables, columns). Alters are more complex.
  • Usually a safe delete is done in the following steps
    • pseudo delete by rename
      • rename column - in case of issue the rename can be reverted with almost no penalty cost.
      • also alter the column to have default values inserted since the code will not know that the column exists anymore, you also want to be able to do the revert so the column need a value
    • real delete
      • the code already executed and didn't noticed (issues) that the column doesn't have the old name

Resources