Skip to main content

Migration Templates

Hysteria ORM provides templates and helpers for common migration patterns.

Basic Migration Template

import { Migration } from 'hysteria-orm';

export default class extends Migration {
async up() {
// Your migration logic here
}
async down() {
// Your rollback logic here
}
}

Create Table Template

this.schema.createTable('table_name', (table) => {
table.bigSerial('id').primary();
table.string('name');
// ...
});

Alter Table Template

this.schema.alterTable('table_name', (table) => {
table.addColumn('new_column', 'string');
// ...
});

See src/cli/resources/migration_templates.ts for more examples and advanced usage.