Problem
Currently, MSR migration scripts require implementing the full IMigrationScript interface with getVersion(), getDescription(), and execute() methods. This is more complex than competitors and makes migrations harder to write.
Proposed Solution
Simplify the migration script interface to match industry standard patterns used by Knex.js, Sequelize, Rails, Alembic, and others:
// Current (complex)
export default class V1_CreateUsersTable implements IMigrationScript {
getVersion(): string { return '1'; }
getDescription(): string { return 'Create users table'; }
async execute(db: any): Promise<void> { /* migration logic */ }
}
// Proposed (simple)
export async function up(db: any): Promise<void> {
// Forward migration
}
export async function down(db: any): Promise<void> {
// Rollback migration
}
Benefits
- Familiar Pattern: Matches what developers expect from other migration tools
- Less Boilerplate: No need to implement interface, getVersion(), getDescription()
- Explicit Rollback: Separate
down function makes rollbacks first-class
- Better DX: Easier to write and understand
Implementation Notes
- Keep backward compatibility with existing
IMigrationScript interface
- Auto-detect which format is used (class vs functions)
- Extract version and description from filename (e.g.,
V1_CreateUsersTable.ts)
- Document migration pattern in getting started guide
Related
Problem
Currently, MSR migration scripts require implementing the full
IMigrationScriptinterface withgetVersion(),getDescription(), andexecute()methods. This is more complex than competitors and makes migrations harder to write.Proposed Solution
Simplify the migration script interface to match industry standard patterns used by Knex.js, Sequelize, Rails, Alembic, and others:
Benefits
downfunction makes rollbacks first-classImplementation Notes
IMigrationScriptinterfaceV1_CreateUsersTable.ts)Related