fix(core): Fix migrations for MySQL/MariaDB (#6591)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™ 2023-07-04 16:02:40 +02:00 committed by कारतोफ्फेलस्क्रिप्ट™
parent 2580286a19
commit b9da67b653
3 changed files with 21 additions and 2 deletions

View file

@ -6,7 +6,7 @@ export class SeparateExecutionData1690000000030 implements ReversibleMigration {
`CREATE TABLE ${tablePrefix}execution_data (
executionId int(11) NOT NULL primary key,
workflowData json NOT NULL,
data TEXT NOT NULL,
data MEDIUMTEXT NOT NULL,
CONSTRAINT \`${tablePrefix}execution_data_FK\` FOREIGN KEY (\`executionId\`) REFERENCES \`${tablePrefix}execution_entity\` (\`id\`) ON DELETE CASCADE
)
ENGINE=InnoDB`,
@ -30,7 +30,7 @@ export class SeparateExecutionData1690000000030 implements ReversibleMigration {
await queryRunner.query(
`ALTER TABLE ${tablePrefix}execution_entity
ADD workflowData json NULL,
ADD data text NULL`,
ADD data MEDIUMTEXT NULL`,
);
await queryRunner.query(

View file

@ -0,0 +1,17 @@
import type { MigrationContext, IrreversibleMigration } from '@db/types';
export class FixExecutionDataType1690000000031 implements IrreversibleMigration {
async up({ queryRunner, tablePrefix }: MigrationContext) {
/**
* SeparateExecutionData migration for MySQL/MariaDB accidentally changed the data-type for `data` column to `TEXT`.
* This migration changes it back.
* The previous migration has been patched to avoid converting to `TEXT`, which might fail.
*
* For any users who already ran the previous migration, this migration should fix the column type.
* For any users who run these migrations in the same batch, this migration would be no-op, as the column type is already `MEDIUMTEXT`
*/
await queryRunner.query(
'ALTER TABLE `' + tablePrefix + 'execution_data` MODIFY COLUMN `data` MEDIUMTEXT',
);
}
}

View file

@ -40,6 +40,7 @@ import { CreateVariables1677501636753 } from './1677501636753-CreateVariables';
import { AddUserActivatedProperty1681134145996 } from './1681134145996-AddUserActivatedProperty';
import { MigrateIntegerKeysToString1690000000001 } from './1690000000001-MigrateIntegerKeysToString';
import { SeparateExecutionData1690000000030 } from './1690000000030-SeparateExecutionData';
import { FixExecutionDataType1690000000031 } from './1690000000031-FixExecutionDataType';
import { RemoveSkipOwnerSetup1681134145997 } from './1681134145997-RemoveSkipOwnerSetup';
export const mysqlMigrations: Migration[] = [
@ -84,5 +85,6 @@ export const mysqlMigrations: Migration[] = [
AddUserActivatedProperty1681134145996,
MigrateIntegerKeysToString1690000000001,
SeparateExecutionData1690000000030,
FixExecutionDataType1690000000031,
RemoveSkipOwnerSetup1681134145997,
];