feat(core): Migration for soft deletions for executions (#7088)

Based on https://github.com/n8n-io/n8n/pull/7065

---------

Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
Iván Ovejero
2023-09-04 14:34:03 +02:00
committed by GitHub
parent 58e55ba669
commit 413e0bccb4
6 changed files with 33 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
import type { MigrationContext, ReversibleMigration } from '@/databases/types';
/**
* Add an indexed column `deletedAt` to track soft-deleted executions.
* Add an index on `stoppedAt`, used by executions pruning.
*/
export class ExecutionSoftDelete1693491613982 implements ReversibleMigration {
async up({ schemaBuilder: { addColumns, column, createIndex } }: MigrationContext) {
await addColumns('execution_entity', [column('deletedAt').timestamp()]);
await createIndex('execution_entity', ['deletedAt']);
await createIndex('execution_entity', ['stoppedAt']);
}
async down({ schemaBuilder: { dropColumns, dropIndex } }: MigrationContext) {
await dropIndex('execution_entity', ['stoppedAt']);
await dropIndex('execution_entity', ['deletedAt']);
await dropColumns('execution_entity', ['deletedAt']);
}
}