mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-09 20:07:31 -08:00
698d96a617
* refactor: use consistent folder structure across workflow, core, and cli * setup typescript project references across workflow, core, and cli
47 lines
1.1 KiB
TypeScript
47 lines
1.1 KiB
TypeScript
import {
|
|
logMigrationStart,
|
|
logMigrationEnd,
|
|
runInBatches,
|
|
getTablePrefix,
|
|
} from '@db/utils/migrationHelpers';
|
|
import { addJsonKeyToPinDataColumn } from '../sqlite/1659888469333-AddJsonKeyPinData';
|
|
import type { MigrationInterface, QueryRunner } from 'typeorm';
|
|
|
|
/**
|
|
* Convert JSON-type `pinData` column in `workflow_entity` table from
|
|
* `{ [nodeName: string]: IDataObject[] }` to `{ [nodeName: string]: INodeExecutionData[] }`
|
|
*/
|
|
export class AddJsonKeyPinData1659895550980 implements MigrationInterface {
|
|
name = 'AddJsonKeyPinData1659895550980';
|
|
|
|
async up(queryRunner: QueryRunner) {
|
|
logMigrationStart(this.name);
|
|
|
|
const workflowTable = `${getTablePrefix()}workflow_entity`;
|
|
|
|
const PINDATA_SELECT_QUERY = `
|
|
SELECT id, pinData
|
|
FROM \`${workflowTable}\`
|
|
WHERE pinData IS NOT NULL;
|
|
`;
|
|
|
|
const PINDATA_UPDATE_STATEMENT = `
|
|
UPDATE \`${workflowTable}\`
|
|
SET \`pinData\` = :pinData
|
|
WHERE id = :id;
|
|
`;
|
|
|
|
await runInBatches(
|
|
queryRunner,
|
|
PINDATA_SELECT_QUERY,
|
|
addJsonKeyToPinDataColumn(queryRunner, PINDATA_UPDATE_STATEMENT),
|
|
);
|
|
|
|
logMigrationEnd(this.name);
|
|
}
|
|
|
|
async down() {
|
|
// irreversible migration
|
|
}
|
|
}
|