Decouple Pre-deployment and Post-deployment Migrations with Explicit Dependencies

Follow up from #1516 (closed)

Goal

Implement Option B to decouple Pre-deployment and Post-deployment Migrations with Explicit Dependencies**

Instead of relying on a sequential versioning system, we should:

  1. Separate Pre-deployment and Post-deployment migration versioning, ensuring they do not interfere unless explicitly dependent.
  2. Introduce a dependency graph that enforces when an Pre-deployment migration relies on a prior Post-deployment migration.

Pros:

  • Maintains zero-downtime guarantees.
  • Allows greater flexibility—non-dependent Post-deployment and Pre-deployment migrations can be introduced at any time.

Cons:

  • None significant.

Conclusion

I recommend option B because it decouples Pre-deployment and Post-deployment migrations, allowing greater flexibility in introducing schema changes without being constrained by strict version sequencing. This prevents migration bottlenecks, enables faster emergency fixes, and ensures smoother upgrades for self-managed users by enforcing explicit dependencies instead of relying on sequential ordering. However, this comes at the cost of increased implementation complexity, requiring a dependency tracking mechanism for stronger enforcement rules.

Edited by SAhmed