exports.up = function (knex) { return knex.schema.createTable('custom_migrations', (table) => { table.uuid('id').primary().defaultTo(knex.raw('(UUID())')); table.uuid('tenantId').notNullable(); table.string('name', 255).notNullable(); table.text('description'); table.enum('type', [ 'create_table', 'add_column', 'alter_column', 'add_index', 'drop_table', 'custom', ]).notNullable(); table.text('sql').notNullable(); table.enum('status', ['pending', 'executed', 'failed']).defaultTo('pending'); table.timestamp('executedAt').nullable(); table.text('error').nullable(); table.timestamps(true, true); table.index(['tenantId']); table.index(['status']); table.index(['created_at']); }); }; exports.down = function (knex) { return knex.schema.dropTableIfExists('custom_migrations'); };