Skip to content

Commit

Permalink
fix(core): Fix migrations for MySQL/MariaDB (#6591)
Browse files Browse the repository at this point in the history
  • Loading branch information
netroy committed Jul 4, 2023
1 parent 2580286 commit b9da67b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
@@ -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',
);
}
}
2 changes: 2 additions & 0 deletions packages/cli/src/databases/migrations/mysqldb/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = [
Expand Down Expand Up @@ -84,5 +85,6 @@ export const mysqlMigrations: Migration[] = [
AddUserActivatedProperty1681134145996,
MigrateIntegerKeysToString1690000000001,
SeparateExecutionData1690000000030,
FixExecutionDataType1690000000031,
RemoveSkipOwnerSetup1681134145997,
];

0 comments on commit b9da67b

Please sign in to comment.