mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 20:54:07 -08:00
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:
parent
04e3178901
commit
a4578d68a5
|
@ -93,6 +93,9 @@ export class Column {
|
|||
options.type = isPostgres ? 'timestamptz' : 'datetime';
|
||||
} else if (type === 'json' && isSqlite) {
|
||||
options.type = 'text';
|
||||
} else if (type === 'uuid' && isMysql) {
|
||||
// mysql does not support uuid type
|
||||
options.type = 'varchar(36)';
|
||||
}
|
||||
|
||||
if ((type === 'varchar' || type === 'timestamp') && length !== 'auto') {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -45,6 +45,7 @@ import { RemoveSkipOwnerSetup1681134145997 } from './1681134145997-RemoveSkipOwn
|
|||
import { RemoveResetPasswordColumns1690000000030 } from '../common/1690000000030-RemoveResetPasswordColumns';
|
||||
import { CreateWorkflowNameIndex1691088862123 } from '../common/1691088862123-CreateWorkflowNameIndex';
|
||||
import { AddMfaColumns1690000000030 } from './../common/1690000000040-AddMfaColumns';
|
||||
import { CreateWorkflowHistoryTable1692967111175 } from '../common/1692967111175-CreateWorkflowHistoryTable';
|
||||
|
||||
export const mysqlMigrations: Migration[] = [
|
||||
InitialMigration1588157391238,
|
||||
|
@ -93,4 +94,5 @@ export const mysqlMigrations: Migration[] = [
|
|||
RemoveResetPasswordColumns1690000000030,
|
||||
CreateWorkflowNameIndex1691088862123,
|
||||
AddMfaColumns1690000000030,
|
||||
CreateWorkflowHistoryTable1692967111175,
|
||||
];
|
||||
|
|
|
@ -43,6 +43,7 @@ import { RemoveResetPasswordColumns1690000000030 } from '../common/1690000000030
|
|||
import { AddMissingPrimaryKeyOnExecutionData1690787606731 } from './1690787606731-AddMissingPrimaryKeyOnExecutionData';
|
||||
import { CreateWorkflowNameIndex1691088862123 } from '../common/1691088862123-CreateWorkflowNameIndex';
|
||||
import { AddMfaColumns1690000000030 } from './../common/1690000000040-AddMfaColumns';
|
||||
import { CreateWorkflowHistoryTable1692967111175 } from '../common/1692967111175-CreateWorkflowHistoryTable';
|
||||
|
||||
export const postgresMigrations: Migration[] = [
|
||||
InitialMigration1587669153312,
|
||||
|
@ -89,4 +90,5 @@ export const postgresMigrations: Migration[] = [
|
|||
AddMissingPrimaryKeyOnExecutionData1690787606731,
|
||||
CreateWorkflowNameIndex1691088862123,
|
||||
AddMfaColumns1690000000030,
|
||||
CreateWorkflowHistoryTable1692967111175,
|
||||
];
|
||||
|
|
|
@ -42,6 +42,7 @@ import { FixMissingIndicesFromStringIdMigration1690000000020 } from './169000000
|
|||
import { RemoveResetPasswordColumns1690000000030 } from './1690000000030-RemoveResetPasswordColumns';
|
||||
import { CreateWorkflowNameIndex1691088862123 } from '../common/1691088862123-CreateWorkflowNameIndex';
|
||||
import { AddMfaColumns1690000000030 } from './1690000000040-AddMfaColumns';
|
||||
import { CreateWorkflowHistoryTable1692967111175 } from '../common/1692967111175-CreateWorkflowHistoryTable';
|
||||
|
||||
const sqliteMigrations: Migration[] = [
|
||||
InitialMigration1588102412422,
|
||||
|
@ -87,6 +88,7 @@ const sqliteMigrations: Migration[] = [
|
|||
RemoveResetPasswordColumns1690000000030,
|
||||
CreateWorkflowNameIndex1691088862123,
|
||||
AddMfaColumns1690000000030,
|
||||
CreateWorkflowHistoryTable1692967111175,
|
||||
];
|
||||
|
||||
export { sqliteMigrations };
|
||||
|
|
Loading…
Reference in a new issue