mirror of
https://github.com/n8n-io/n8n.git
synced 2025-02-21 02:56:40 -08:00
🐘 🔧 create postgres migration, remove individual entities
This commit is contained in:
parent
81b738be29
commit
1150121ab1
|
@ -1,45 +0,0 @@
|
||||||
import {
|
|
||||||
ICredentialNodeAccess,
|
|
||||||
} from 'n8n-workflow';
|
|
||||||
|
|
||||||
import {
|
|
||||||
ICredentialsDb,
|
|
||||||
} from '../../';
|
|
||||||
|
|
||||||
import {
|
|
||||||
Column,
|
|
||||||
Entity,
|
|
||||||
Index,
|
|
||||||
PrimaryGeneratedColumn,
|
|
||||||
} from 'typeorm';
|
|
||||||
|
|
||||||
@Entity()
|
|
||||||
export class CredentialsEntity implements ICredentialsDb {
|
|
||||||
|
|
||||||
@PrimaryGeneratedColumn()
|
|
||||||
id: number;
|
|
||||||
|
|
||||||
@Column({
|
|
||||||
length: 128,
|
|
||||||
})
|
|
||||||
name: string;
|
|
||||||
|
|
||||||
@Column('text')
|
|
||||||
data: string;
|
|
||||||
|
|
||||||
@Index()
|
|
||||||
@Column({
|
|
||||||
length: 32,
|
|
||||||
})
|
|
||||||
type: string;
|
|
||||||
|
|
||||||
@Column('json')
|
|
||||||
nodesAccess: ICredentialNodeAccess[];
|
|
||||||
|
|
||||||
@Column('timestamp')
|
|
||||||
createdAt: Date;
|
|
||||||
|
|
||||||
@Column('timestamp')
|
|
||||||
updatedAt: Date;
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,52 +0,0 @@
|
||||||
import {
|
|
||||||
WorkflowExecuteMode,
|
|
||||||
} from 'n8n-workflow';
|
|
||||||
|
|
||||||
import {
|
|
||||||
IExecutionFlattedDb,
|
|
||||||
IWorkflowDb,
|
|
||||||
} from '../../';
|
|
||||||
|
|
||||||
import {
|
|
||||||
Column,
|
|
||||||
Entity,
|
|
||||||
Index,
|
|
||||||
PrimaryGeneratedColumn,
|
|
||||||
} from 'typeorm';
|
|
||||||
|
|
||||||
|
|
||||||
@Entity()
|
|
||||||
export class ExecutionEntity implements IExecutionFlattedDb {
|
|
||||||
|
|
||||||
@PrimaryGeneratedColumn()
|
|
||||||
id: number;
|
|
||||||
|
|
||||||
@Column('text')
|
|
||||||
data: string;
|
|
||||||
|
|
||||||
@Column()
|
|
||||||
finished: boolean;
|
|
||||||
|
|
||||||
@Column('varchar')
|
|
||||||
mode: WorkflowExecuteMode;
|
|
||||||
|
|
||||||
@Column({ nullable: true })
|
|
||||||
retryOf: string;
|
|
||||||
|
|
||||||
@Column({ nullable: true })
|
|
||||||
retrySuccessId: string;
|
|
||||||
|
|
||||||
@Column('timestamp')
|
|
||||||
startedAt: Date;
|
|
||||||
|
|
||||||
@Index()
|
|
||||||
@Column('timestamp', { nullable: true })
|
|
||||||
stoppedAt: Date;
|
|
||||||
|
|
||||||
@Column('json')
|
|
||||||
workflowData: IWorkflowDb;
|
|
||||||
|
|
||||||
@Index()
|
|
||||||
@Column({ nullable: true })
|
|
||||||
workflowId: string;
|
|
||||||
}
|
|
|
@ -1,33 +0,0 @@
|
||||||
import {
|
|
||||||
Column,
|
|
||||||
Entity,
|
|
||||||
Index,
|
|
||||||
PrimaryColumn,
|
|
||||||
} from 'typeorm';
|
|
||||||
|
|
||||||
import {
|
|
||||||
IWebhookDb,
|
|
||||||
} from '../../';
|
|
||||||
|
|
||||||
@Entity()
|
|
||||||
@Index(['webhookId', 'method', 'pathLength'])
|
|
||||||
export class WebhookEntity implements IWebhookDb {
|
|
||||||
|
|
||||||
@Column()
|
|
||||||
workflowId: number;
|
|
||||||
|
|
||||||
@PrimaryColumn()
|
|
||||||
webhookPath: string;
|
|
||||||
|
|
||||||
@PrimaryColumn()
|
|
||||||
method: string;
|
|
||||||
|
|
||||||
@Column()
|
|
||||||
node: string;
|
|
||||||
|
|
||||||
@Column({ nullable: true })
|
|
||||||
webhookId: string;
|
|
||||||
|
|
||||||
@Column({ nullable: true })
|
|
||||||
pathLength: number;
|
|
||||||
}
|
|
|
@ -1,55 +0,0 @@
|
||||||
import {
|
|
||||||
IConnections,
|
|
||||||
IDataObject,
|
|
||||||
INode,
|
|
||||||
IWorkflowSettings,
|
|
||||||
} from 'n8n-workflow';
|
|
||||||
|
|
||||||
import {
|
|
||||||
IWorkflowDb,
|
|
||||||
} from '../../';
|
|
||||||
|
|
||||||
import {
|
|
||||||
Column,
|
|
||||||
Entity,
|
|
||||||
PrimaryGeneratedColumn,
|
|
||||||
} from 'typeorm';
|
|
||||||
|
|
||||||
@Entity()
|
|
||||||
export class WorkflowEntity implements IWorkflowDb {
|
|
||||||
|
|
||||||
@PrimaryGeneratedColumn()
|
|
||||||
id: number;
|
|
||||||
|
|
||||||
@Column({
|
|
||||||
length: 128,
|
|
||||||
})
|
|
||||||
name: string;
|
|
||||||
|
|
||||||
@Column()
|
|
||||||
active: boolean;
|
|
||||||
|
|
||||||
@Column('json')
|
|
||||||
nodes: INode[];
|
|
||||||
|
|
||||||
@Column('json')
|
|
||||||
connections: IConnections;
|
|
||||||
|
|
||||||
@Column('timestamp')
|
|
||||||
createdAt: Date;
|
|
||||||
|
|
||||||
@Column('timestamp')
|
|
||||||
updatedAt: Date;
|
|
||||||
|
|
||||||
@Column({
|
|
||||||
type: 'json',
|
|
||||||
nullable: true,
|
|
||||||
})
|
|
||||||
settings?: IWorkflowSettings;
|
|
||||||
|
|
||||||
@Column({
|
|
||||||
type: 'json',
|
|
||||||
nullable: true,
|
|
||||||
})
|
|
||||||
staticData?: IDataObject;
|
|
||||||
}
|
|
|
@ -1,5 +0,0 @@
|
||||||
export * from './CredentialsEntity';
|
|
||||||
export * from './ExecutionEntity';
|
|
||||||
export * from './WorkflowEntity';
|
|
||||||
export * from './WebhookEntity';
|
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
import {MigrationInterface, QueryRunner} from "typeorm";
|
||||||
|
import * as config from '../../../../config';
|
||||||
|
|
||||||
|
export class CreateTagEntity1617270242566 implements MigrationInterface {
|
||||||
|
name = 'CreateTagEntity1617270242566'
|
||||||
|
|
||||||
|
async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
let tablePrefix = config.get('database.tablePrefix');
|
||||||
|
const tablePrefixPure = tablePrefix;
|
||||||
|
const schema = config.get('database.postgresdb.schema');
|
||||||
|
if (schema) {
|
||||||
|
tablePrefix = schema + '.' + tablePrefix;
|
||||||
|
}
|
||||||
|
|
||||||
|
await queryRunner.query(`CREATE TABLE ${tablePrefix}tag_entity ("id" SERIAL NOT NULL, "name" character varying(24) NOT NULL, "createdAt" TIMESTAMP NOT NULL, "updatedAt" TIMESTAMP NOT NULL, CONSTRAINT "PK_${tablePrefixPure}7a50a9b74ae6855c0dcaee25052" PRIMARY KEY ("id"))`);
|
||||||
|
await queryRunner.query(`CREATE UNIQUE INDEX IDX_${tablePrefixPure}812eb05f7451ca757fb98444ce ON ${tablePrefix}tag_entity ("name") `);
|
||||||
|
|
||||||
|
await queryRunner.query(`CREATE TABLE ${tablePrefix}workflows_tags ("workflowId" integer NOT NULL, "tagId" integer NOT NULL, CONSTRAINT "PK_${tablePrefixPure}a60448a90e51a114e95e2a125b3" PRIMARY KEY ("workflowId", "tagId"))`);
|
||||||
|
await queryRunner.query(`CREATE INDEX IDX_${tablePrefixPure}31140eb41f019805b40d008744 ON ${tablePrefix}workflows_tags ("workflowId") `);
|
||||||
|
await queryRunner.query(`CREATE INDEX IDX_${tablePrefixPure}5e29bfe9e22c5d6567f509d4a4 ON ${tablePrefix}workflows_tags ("tagId") `);
|
||||||
|
await queryRunner.query(`ALTER TABLE ${tablePrefix}workflows_tags ADD CONSTRAINT "FK_${tablePrefixPure}31140eb41f019805b40d0087449" FOREIGN KEY ("workflowId") REFERENCES ${tablePrefix}workflow_entity ("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
|
||||||
|
await queryRunner.query(`ALTER TABLE ${tablePrefix}workflows_tags ADD CONSTRAINT "FK_${tablePrefixPure}5e29bfe9e22c5d6567f509d4a46" FOREIGN KEY ("tagId") REFERENCES ${tablePrefix}tag_entity ("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
|
||||||
|
}
|
||||||
|
|
||||||
|
async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
let tablePrefix = config.get('database.tablePrefix');
|
||||||
|
const tablePrefixPure = tablePrefix;
|
||||||
|
const schema = config.get('database.postgresdb.schema');
|
||||||
|
if (schema) {
|
||||||
|
tablePrefix = schema + '.' + tablePrefix;
|
||||||
|
}
|
||||||
|
|
||||||
|
await queryRunner.query(`ALTER TABLE ${tablePrefix}workflows_tags DROP CONSTRAINT "FK_${tablePrefixPure}5e29bfe9e22c5d6567f509d4a46"`);
|
||||||
|
await queryRunner.query(`ALTER TABLE ${tablePrefix}workflows_tags DROP CONSTRAINT "FK_${tablePrefixPure}31140eb41f019805b40d0087449"`);
|
||||||
|
await queryRunner.query(`DROP INDEX IDX_${tablePrefixPure}5e29bfe9e22c5d6567f509d4a4`);
|
||||||
|
await queryRunner.query(`DROP INDEX IDX_${tablePrefixPure}31140eb41f019805b40d008744`);
|
||||||
|
await queryRunner.query(`DROP TABLE ${tablePrefix}workflows_tags`);
|
||||||
|
await queryRunner.query(`DROP INDEX IDX_${tablePrefixPure}812eb05f7451ca757fb98444ce`);
|
||||||
|
await queryRunner.query(`DROP TABLE ${tablePrefix}tag_entity`);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -3,6 +3,7 @@ import { WebhookModel1589476000887 } from './1589476000887-WebhookModel';
|
||||||
import { CreateIndexStoppedAt1594828256133 } from './1594828256133-CreateIndexStoppedAt';
|
import { CreateIndexStoppedAt1594828256133 } from './1594828256133-CreateIndexStoppedAt';
|
||||||
import { AddWebhookId1611144599516 } from './1611144599516-AddWebhookId';
|
import { AddWebhookId1611144599516 } from './1611144599516-AddWebhookId';
|
||||||
import { MakeStoppedAtNullable1607431743768 } from './1607431743768-MakeStoppedAtNullable';
|
import { MakeStoppedAtNullable1607431743768 } from './1607431743768-MakeStoppedAtNullable';
|
||||||
|
import { CreateTagEntity1617270242566 } from './1617270242566-CreateTagEntity';
|
||||||
|
|
||||||
export const postgresMigrations = [
|
export const postgresMigrations = [
|
||||||
InitialMigration1587669153312,
|
InitialMigration1587669153312,
|
||||||
|
@ -10,4 +11,5 @@ export const postgresMigrations = [
|
||||||
CreateIndexStoppedAt1594828256133,
|
CreateIndexStoppedAt1594828256133,
|
||||||
AddWebhookId1611144599516,
|
AddWebhookId1611144599516,
|
||||||
MakeStoppedAtNullable1607431743768,
|
MakeStoppedAtNullable1607431743768,
|
||||||
|
CreateTagEntity1617270242566,
|
||||||
];
|
];
|
||||||
|
|
Loading…
Reference in a new issue