Incremental Database Migrations

One of the causes of headaches for active development is database migrations.  Code that requires new tables or new columns in existing tables simply won’t work if the database migration hasn’t been applied.

This is different from code, which could (safely) use introspection to see if a field in a class exists, or simply just recompile the entire project monolithically.  New, unused members can safely be added, and can even be safely discarded when using a compiling language like C# or Java.

It is not even safe to add additional columns, as we discovered in production recently:

When adding a new column to a table which has an identical name to an existing column in another table, and those tables are joined, SQL queries can fail because the selector field or the WHERE clauses may become ambiguous.

So, another point for using an ORM.

Leave a Reply

Your email address will not be published. Required fields are marked *