mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
25 lines
795 B
TypeScript
25 lines
795 B
TypeScript
|
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
|
||
|
|
||
|
const testMetricEntityTableName = 'test_metric';
|
||
|
|
||
|
export class CreateTestMetricTable1732271325258 implements ReversibleMigration {
|
||
|
async up({ schemaBuilder: { createTable, column } }: MigrationContext) {
|
||
|
await createTable(testMetricEntityTableName)
|
||
|
.withColumns(
|
||
|
column('id').varchar(36).primary.notNull,
|
||
|
column('name').varchar(255).notNull,
|
||
|
column('testDefinitionId').varchar(36).notNull,
|
||
|
)
|
||
|
.withIndexOn('testDefinitionId')
|
||
|
.withForeignKey('testDefinitionId', {
|
||
|
tableName: 'test_definition',
|
||
|
columnName: 'id',
|
||
|
onDelete: 'CASCADE',
|
||
|
}).withTimestamps;
|
||
|
}
|
||
|
|
||
|
async down({ schemaBuilder: { dropTable } }: MigrationContext) {
|
||
|
await dropTable(testMetricEntityTableName);
|
||
|
}
|
||
|
}
|