Files
Automata/packages/cli/src/databases/migrations/common/1692967111175-CreateWorkflowHistoryTable.ts
कारतोफ्फेलस्क्रिप्ट™ ab9835126e refactor(core): Use @/databases/ instead of @db/ (no-changelog) (#10573)
2024-08-27 17:24:20 +02:00

27 lines
823 B
TypeScript

import type { MigrationContext, ReversibleMigration } from '@/databases/types';
const tableName = 'workflow_history';
export class CreateWorkflowHistoryTable1692967111175 implements ReversibleMigration {
async up({ schemaBuilder: { createTable, column } }: MigrationContext) {
await createTable(tableName)
.withColumns(
column('versionId').varchar(36).primary.notNull,
column('workflowId').varchar(36).notNull,
column('nodes').text.notNull,
column('connections').text.notNull,
column('authors').varchar(255).notNull,
)
.withTimestamps.withIndexOn('workflowId')
.withForeignKey('workflowId', {
tableName: 'workflow_entity',
columnName: 'id',
onDelete: 'CASCADE',
});
}
async down({ schemaBuilder: { dropTable } }: MigrationContext) {
await dropTable(tableName);
}
}