Version Numbering Strategies
Strategy 1: Timestamp-Based (Recommended)
YYYYMMDDHHmmss
Advantages:
- ✅ No merge conflicts with parallel development
- ✅ Chronological ordering
- ✅ Supports distributed teams
- ⚠️ Less human-readable
- ⚠️ Doesn’t convey significance
Strategy 2: Semantic Versioning
v<major>.<minor>.<patch>
Advantages:
- ✅ Conveys change significance
- ✅ Aligns with application versioning
- ✅ Clear breaking change indication
- ⚠️ Requires coordination
- ⚠️ Merge conflicts possible
Strategy 3: Sequential with Milestones
- ✅ Simple and clear
- ✅ Milestones mark releases
- ⚠️ Merge conflicts in parallel work
- ⚠️ Gaps can be confusing
Migration File Best Practices
Keep Migrations Small
- ✅ Good - Focused
- ❌ Bad - Too Large
- Single, clear purpose
- Fast execution
- Easy to review
- Simple to rollback
Include Rollback Planning
Document rollback approach in comments:Transaction Handling
Bytebase Automatic Transactions: Bytebase automatically wraps all SQL statements in a migration file within a single transaction. You typically don’t need to add explicit
BEGIN/COMMIT statements.- Single-file migrations with multiple statements
- Standard DDL operations (CREATE, ALTER, DROP)
- Simple DML operations (INSERT, UPDATE, DELETE)
- Batched operations requiring commits between chunks
- Long-running data migrations that need progress checkpoints
- Statements that cannot run in a transaction block — Bytebase auto-detects the common PostgreSQL ones (
CREATE INDEX CONCURRENTLY,DROP INDEX CONCURRENTLY,VACUUM,DROP DATABASE) and runs them outside the transaction for you. For others, disable transaction mode. See Statements that cannot run in a transaction block
- ✅ PostgreSQL: DDL in transactions (except
CONCURRENTLYoperations) - ❌ MySQL: DDL commits immediately (implicit commit)
- ✅ SQL Server: DDL in transactions
Add Comments for Complex Logic
Documentation
Maintain Migration Changelog
Document significant schema changes:Document Schema Dependencies
Track dependencies between application and schema:Common Anti-Patterns to Avoid
❌ Modifying Applied Migrations
Don’t:❌ Skipping Version Numbers
Don’t:❌ Mixing DDL and DML Without Suffix
Don’t:❌ Long-Running Migrations in Production
Don’t:Next Steps
Git and CI/CD
Learn branching strategies and testing patterns
Performance
Optimize migration performance

