Cleanup and Deploy Like the Pros

Learn about schema changes, contraction, principle of undetectability, modeling tools to create schema, cleanup, and deploying the code.

Removing shims

I always tell my kids that a job isn’t done until the tools are put away. Way back in the preparation phase, we applied the database expansions and added shims. The time has come to finish that task.

Removing shims is the easy part. Once every instance is on the new code, those triggers are no longer necessary, so we can just delete them. Do put the deletion into a new migration, though.

Contraction

It’s also time now to apply another round of schema changes. This is contraction, or tightening down the schema:

  • Drop old tables.

  • Drop old views.

  • Drop old columns.

  • Drop aliases and synonyms that are no longer used.

  • Drop stored procedures that are no longer called.

  • Apply NOT NULL constraints on the new columns.

  • Apply foreign key constraints.

Principle of undetectability

Most of those are pretty obvious. The exceptions are the two kinds of constraint. We can only add constraints after the rollout. That’s because the old application version wouldn’t know how to satisfy them. Instances ...