# Destructive Operations & Zero-Downtime Patterns

When a migration contains destructive operations (DropColumn, RenameColumn, AlterColumn, DropTable), consider zero-downtime patterns for production deployments.

## Detection

Migration Analysis counts:
- DropColumn
- RenameColumn
- AlterColumn
- DropTable

If any count > 0, display warning and reference this document.

## Zero-Downtime Patterns

For production deployments with destructive operations:

1. **Add → Populate → Migrate → Remove** (for column renames)
   - Add new column
   - Populate from old column
   - Deploy migration
   - Remove old column in next deployment window

2. **Feature Flags** (for table changes)
   - Add feature flag
   - Deploy new code path
   - Migrate data
   - Remove old code path after stabilization

3. **Gradual Rollout**
   - Deploy to staging first
   - Monitor for issues
   - Gradually roll to production clusters

## Reference

See OWASP and database migration best practices for your platform.
