feat: Create workflow history database migration (no-changelog) (#7031)
Github issue / Community forum post (link here to close automatically): For the upcoming workflow history feature, we're creating the necessary database tables. Also changes the schema for Postgres so the versionId column is now properly a UUID. The `using` statement prevents losing data, basically converting the strings to UUIDs. --------- Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <netroy@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import type { MigrationContext, ReversibleMigration } from '@db/types';
|
||||
|
||||
const tableName = 'workflow_history';
|
||||
|
||||
export class CreateWorkflowHistoryTable1692967111175 implements ReversibleMigration {
|
||||
async up({ schemaBuilder: { createTable, column }, queryRunner }: 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',
|
||||
})
|
||||
.execute(queryRunner);
|
||||
}
|
||||
|
||||
async down({ schemaBuilder: { dropTable } }: MigrationContext) {
|
||||
await dropTable(tableName);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user