mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2026-07-29 16:18:50 +02:00
* refactor: use consistent folder structure across workflow, core, and cli * setup typescript project references across workflow, core, and cli
34 lines
1.4 KiB
TypeScript
34 lines
1.4 KiB
TypeScript
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
import { getTablePrefix, logMigrationEnd, logMigrationStart } from '@db/utils/migrationHelpers';
|
|
|
|
export class CreateCredentialUsageTable1665484192211 implements MigrationInterface {
|
|
name = 'CreateCredentialUsageTable1665484192211';
|
|
|
|
async up(queryRunner: QueryRunner) {
|
|
logMigrationStart(this.name);
|
|
|
|
const tablePrefix = getTablePrefix();
|
|
|
|
await queryRunner.query(
|
|
`CREATE TABLE "${tablePrefix}credential_usage" (` +
|
|
`"workflowId" integer NOT NULL,` +
|
|
`"nodeId" varchar NOT NULL,` +
|
|
`"credentialId" integer NOT NULL,` +
|
|
`"createdAt" datetime(3) NOT NULL DEFAULT 'STRFTIME(''%Y-%m-%d %H:%M:%f'', ''NOW'')',` +
|
|
`"updatedAt" datetime(3) NOT NULL DEFAULT 'STRFTIME(''%Y-%m-%d %H:%M:%f'', ''NOW'')',` +
|
|
`PRIMARY KEY("workflowId", "nodeId", "credentialId"), ` +
|
|
`CONSTRAINT "FK_${tablePrefix}518e1ece107b859ca6ce9ed2487f7e23" FOREIGN KEY ("workflowId") REFERENCES "${tablePrefix}workflow_entity" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, ` +
|
|
`CONSTRAINT "FK_${tablePrefix}7ce200a20ade7ae89fa7901da896993f" FOREIGN KEY ("credentialId") REFERENCES "${tablePrefix}credentials_entity" ("id") ON DELETE CASCADE ON UPDATE NO ACTION ` +
|
|
`);`,
|
|
);
|
|
|
|
logMigrationEnd(this.name);
|
|
}
|
|
|
|
async down(queryRunner: QueryRunner) {
|
|
const tablePrefix = getTablePrefix();
|
|
|
|
await queryRunner.query(`DROP TABLE "${tablePrefix}credential_usage"`);
|
|
}
|
|
}
|