@atom8n/db 1.4.2 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -30,7 +30,7 @@ export declare class User extends WithTimestamps implements IUser, AuthPrincipal
30
30
  lastActiveAt?: Date | null;
31
31
  isPending: boolean;
32
32
  computeIsPending(): void;
33
- toJSON(): Omit<this, "setUpdateDate" | "password" | "preUpsertHook" | "mfaSecret" | "mfaRecoveryCodes" | "computeIsPending" | "toJSON" | "createPersonalProjectName" | "toIUser">;
33
+ toJSON(): Omit<this, "setUpdateDate" | "password" | "mfaSecret" | "mfaRecoveryCodes" | "preUpsertHook" | "computeIsPending" | "toJSON" | "createPersonalProjectName" | "toIUser">;
34
34
  createPersonalProjectName(): string;
35
35
  toIUser(): IUser;
36
36
  }
@@ -0,0 +1,5 @@
1
+ import type { ReversibleMigration, MigrationContext } from '../migration-types';
2
+ export declare class ExpandModelColumnLength1768402473068 implements ReversibleMigration {
3
+ up({ isSqlite, isPostgres, escape, queryRunner }: MigrationContext): Promise<void>;
4
+ down({ isSqlite, isPostgres, escape, queryRunner }: MigrationContext): Promise<void>;
5
+ }
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExpandModelColumnLength1768402473068 = void 0;
4
+ class ExpandModelColumnLength1768402473068 {
5
+ async up({ isSqlite, isPostgres, escape, queryRunner }) {
6
+ const messagesTable = escape.tableName('chat_hub_messages');
7
+ const sessionsTable = escape.tableName('chat_hub_sessions');
8
+ const modelColumn = escape.columnName('model');
9
+ if (isPostgres) {
10
+ await queryRunner.query(`ALTER TABLE ${messagesTable} ALTER COLUMN ${modelColumn} TYPE VARCHAR(256);`);
11
+ await queryRunner.query(`ALTER TABLE ${sessionsTable} ALTER COLUMN ${modelColumn} TYPE VARCHAR(256);`);
12
+ }
13
+ else if (isSqlite) {
14
+ for (const table of [messagesTable, sessionsTable]) {
15
+ await queryRunner.query(`ALTER TABLE ${table} ADD COLUMN "model_tmp" VARCHAR(256);`);
16
+ await queryRunner.query(`UPDATE ${table} SET "model_tmp" = ${modelColumn};`);
17
+ await queryRunner.query(`ALTER TABLE ${table} DROP COLUMN ${modelColumn};`);
18
+ await queryRunner.query(`ALTER TABLE ${table} ADD COLUMN ${modelColumn} VARCHAR(256);`);
19
+ await queryRunner.query(`UPDATE ${table} SET ${modelColumn} = "model_tmp";`);
20
+ await queryRunner.query(`ALTER TABLE ${table} DROP COLUMN "model_tmp";`);
21
+ }
22
+ }
23
+ }
24
+ async down({ isSqlite, isPostgres, escape, queryRunner }) {
25
+ const messagesTable = escape.tableName('chat_hub_messages');
26
+ const sessionsTable = escape.tableName('chat_hub_sessions');
27
+ const modelColumn = escape.columnName('model');
28
+ if (isPostgres) {
29
+ await queryRunner.query(`UPDATE ${messagesTable} SET ${modelColumn} = LEFT(${modelColumn}, 64) WHERE LENGTH(${modelColumn}) > 64;`);
30
+ await queryRunner.query(`UPDATE ${sessionsTable} SET ${modelColumn} = LEFT(${modelColumn}, 64) WHERE LENGTH(${modelColumn}) > 64;`);
31
+ await queryRunner.query(`ALTER TABLE ${messagesTable} ALTER COLUMN ${modelColumn} TYPE VARCHAR(64);`);
32
+ await queryRunner.query(`ALTER TABLE ${sessionsTable} ALTER COLUMN ${modelColumn} TYPE VARCHAR(64);`);
33
+ }
34
+ else if (isSqlite) {
35
+ for (const table of [messagesTable, sessionsTable]) {
36
+ await queryRunner.query(`ALTER TABLE ${table} ADD COLUMN "model_tmp" VARCHAR(64);`);
37
+ await queryRunner.query(`UPDATE ${table} SET "model_tmp" = SUBSTR(${modelColumn}, 1, 64);`);
38
+ await queryRunner.query(`ALTER TABLE ${table} DROP COLUMN ${modelColumn};`);
39
+ await queryRunner.query(`ALTER TABLE ${table} ADD COLUMN ${modelColumn} VARCHAR(64);`);
40
+ await queryRunner.query(`UPDATE ${table} SET ${modelColumn} = "model_tmp";`);
41
+ await queryRunner.query(`ALTER TABLE ${table} DROP COLUMN "model_tmp";`);
42
+ }
43
+ }
44
+ }
45
+ }
46
+ exports.ExpandModelColumnLength1768402473068 = ExpandModelColumnLength1768402473068;
@@ -0,0 +1,5 @@
1
+ import type { MigrationContext, ReversibleMigration } from '../migration-types';
2
+ export declare class AddStoredAtToExecutionEntity1768557000000 implements ReversibleMigration {
3
+ up({ escape, runQuery }: MigrationContext): Promise<void>;
4
+ down({ escape, runQuery }: MigrationContext): Promise<void>;
5
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AddStoredAtToExecutionEntity1768557000000 = void 0;
4
+ class AddStoredAtToExecutionEntity1768557000000 {
5
+ async up({ escape, runQuery }) {
6
+ const executionEntity = escape.tableName('execution_entity');
7
+ const storedAt = escape.columnName('storedAt');
8
+ await runQuery(`ALTER TABLE ${executionEntity} ADD COLUMN ${storedAt} VARCHAR(2) NOT NULL DEFAULT 'db' CHECK(${storedAt} IN ('db', 'fs', 's3'))`);
9
+ }
10
+ async down({ escape, runQuery }) {
11
+ const executionEntity = escape.tableName('execution_entity');
12
+ const storedAt = escape.columnName('storedAt');
13
+ await runQuery(`ALTER TABLE ${executionEntity} DROP COLUMN ${storedAt}`);
14
+ }
15
+ }
16
+ exports.AddStoredAtToExecutionEntity1768557000000 = AddStoredAtToExecutionEntity1768557000000;
@@ -0,0 +1,5 @@
1
+ import type { MigrationContext, ReversibleMigration } from '../migration-types';
2
+ export declare class AddDynamicCredentialUserEntryTable1768901721000 implements ReversibleMigration {
3
+ up({ schemaBuilder: { createTable, column } }: MigrationContext): Promise<void>;
4
+ down({ schemaBuilder: { dropTable } }: MigrationContext): Promise<void>;
5
+ }
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AddDynamicCredentialUserEntryTable1768901721000 = void 0;
4
+ const tableName = 'dynamic_credential_user_entry';
5
+ class AddDynamicCredentialUserEntryTable1768901721000 {
6
+ async up({ schemaBuilder: { createTable, column } }) {
7
+ await createTable(tableName)
8
+ .withColumns(column('credentialId').varchar(16).primary.notNull, column('userId').uuid.primary.notNull, column('resolverId').varchar(16).primary.notNull, column('data').text.notNull)
9
+ .withTimestamps.withForeignKey('credentialId', {
10
+ tableName: 'credentials_entity',
11
+ columnName: 'id',
12
+ onDelete: 'CASCADE',
13
+ })
14
+ .withForeignKey('resolverId', {
15
+ tableName: 'dynamic_credential_resolver',
16
+ columnName: 'id',
17
+ onDelete: 'CASCADE',
18
+ })
19
+ .withForeignKey('userId', {
20
+ tableName: 'user',
21
+ columnName: 'id',
22
+ onDelete: 'CASCADE',
23
+ })
24
+ .withIndexOn(['userId'])
25
+ .withIndexOn(['resolverId']);
26
+ }
27
+ async down({ schemaBuilder: { dropTable } }) {
28
+ await dropTable(tableName);
29
+ }
30
+ }
31
+ exports.AddDynamicCredentialUserEntryTable1768901721000 = AddDynamicCredentialUserEntryTable1768901721000;
@@ -0,0 +1,4 @@
1
+ import type { IrreversibleMigration, MigrationContext } from '../migration-types';
2
+ export declare class ExpandInsightsWorkflowIdLength1766500000000 implements IrreversibleMigration {
3
+ up({ escape, queryRunner }: MigrationContext): Promise<void>;
4
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExpandInsightsWorkflowIdLength1766500000000 = void 0;
4
+ class ExpandInsightsWorkflowIdLength1766500000000 {
5
+ async up({ escape, queryRunner }) {
6
+ const tableName = escape.tableName('insights_metadata');
7
+ const columnName = escape.columnName('workflowId');
8
+ await queryRunner.query(`ALTER TABLE ${tableName} ALTER COLUMN ${columnName} TYPE VARCHAR(36);`);
9
+ }
10
+ }
11
+ exports.ExpandInsightsWorkflowIdLength1766500000000 = ExpandInsightsWorkflowIdLength1766500000000;
@@ -0,0 +1,5 @@
1
+ import type { MigrationContext, ReversibleMigration } from '../migration-types';
2
+ export declare class ChangeWorkflowStatisticsFKToNoAction1767018516000 implements ReversibleMigration {
3
+ up({ queryRunner, tablePrefix }: MigrationContext): Promise<void>;
4
+ down({ queryRunner, tablePrefix }: MigrationContext): Promise<void>;
5
+ }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ChangeWorkflowStatisticsFKToNoAction1767018516000 = void 0;
4
+ class ChangeWorkflowStatisticsFKToNoAction1767018516000 {
5
+ async up({ queryRunner, tablePrefix }) {
6
+ await queryRunner.query(`ALTER TABLE ${tablePrefix}workflow_statistics DROP CONSTRAINT IF EXISTS "fk_${tablePrefix}workflow_statistics_workflow_id"`);
7
+ await queryRunner.query(`ALTER TABLE ${tablePrefix}workflow_statistics DROP CONSTRAINT IF EXISTS "pk_${tablePrefix}workflow_statistics"`);
8
+ await queryRunner.query(`ALTER TABLE ${tablePrefix}workflow_statistics ADD COLUMN "id" SERIAL PRIMARY KEY`);
9
+ await queryRunner.query(`ALTER TABLE ${tablePrefix}workflow_statistics ADD COLUMN "workflowName" VARCHAR(128)`);
10
+ await queryRunner.query(`UPDATE ${tablePrefix}workflow_statistics ws SET "workflowName" = we."name" FROM ${tablePrefix}workflow_entity we WHERE ws."workflowId" = we."id"`);
11
+ await queryRunner.query(`CREATE UNIQUE INDEX "IDX_${tablePrefix}workflow_statistics_workflow_name" ON ${tablePrefix}workflow_statistics ("workflowId", "name")`);
12
+ await queryRunner.query(`ALTER TABLE ${tablePrefix}workflow_statistics ALTER COLUMN "count" TYPE BIGINT`);
13
+ await queryRunner.query(`ALTER TABLE ${tablePrefix}workflow_statistics ALTER COLUMN "rootCount" TYPE BIGINT`);
14
+ }
15
+ async down({ queryRunner, tablePrefix }) {
16
+ await queryRunner.query(`UPDATE ${tablePrefix}workflow_statistics SET "count" = 0 WHERE "count" > 2147483647`);
17
+ await queryRunner.query(`UPDATE ${tablePrefix}workflow_statistics SET "rootCount" = 0 WHERE "rootCount" > 2147483647`);
18
+ await queryRunner.query(`ALTER TABLE ${tablePrefix}workflow_statistics ALTER COLUMN "count" TYPE INTEGER`);
19
+ await queryRunner.query(`ALTER TABLE ${tablePrefix}workflow_statistics ALTER COLUMN "rootCount" TYPE INTEGER`);
20
+ await queryRunner.query(`DROP INDEX IF EXISTS "IDX_${tablePrefix}workflow_statistics_workflow_name"`);
21
+ await queryRunner.query(`DELETE FROM ${tablePrefix}workflow_statistics WHERE "workflowId" NOT IN (SELECT "id" FROM ${tablePrefix}workflow_entity)`);
22
+ await queryRunner.query(`ALTER TABLE ${tablePrefix}workflow_statistics DROP COLUMN "workflowName"`);
23
+ await queryRunner.query(`ALTER TABLE ${tablePrefix}workflow_statistics DROP COLUMN "id"`);
24
+ await queryRunner.query(`ALTER TABLE ${tablePrefix}workflow_statistics ADD PRIMARY KEY ("workflowId", "name")`);
25
+ await queryRunner.query(`ALTER TABLE ${tablePrefix}workflow_statistics ADD CONSTRAINT "fk_${tablePrefix}workflow_statistics_workflow_id" FOREIGN KEY ("workflowId") REFERENCES ${tablePrefix}workflow_entity(id) ON DELETE CASCADE`);
26
+ }
27
+ }
28
+ exports.ChangeWorkflowStatisticsFKToNoAction1767018516000 = ChangeWorkflowStatisticsFKToNoAction1767018516000;
@@ -50,6 +50,7 @@ const _1761047826451_AddWorkflowVersionColumn_1 = require("./1761047826451-AddWo
50
50
  const _1761655473000_ChangeDependencyInfoToJson_1 = require("./1761655473000-ChangeDependencyInfoToJson");
51
51
  const _1762771264000_ChangeDefaultForIdInUserTable_1 = require("./1762771264000-ChangeDefaultForIdInUserTable");
52
52
  const _1765804780000_ConvertAgentIdToUuid_1 = require("./1765804780000-ConvertAgentIdToUuid");
53
+ const _1766500000000_ExpandInsightsWorkflowIdLength_1 = require("./1766500000000-ExpandInsightsWorkflowIdLength");
53
54
  const _1674509946020_CreateLdapEntities_1 = require("../common/1674509946020-CreateLdapEntities");
54
55
  const _1675940580449_PurgeInvalidWorkflowConnections_1 = require("../common/1675940580449-PurgeInvalidWorkflowConnections");
55
56
  const _1690000000030_RemoveResetPasswordColumns_1 = require("../common/1690000000030-RemoveResetPasswordColumns");
@@ -268,4 +269,5 @@ exports.postgresMigrations = [
268
269
  _1765892199653_AddVersionIdToExecutionData_1.AddWorkflowVersionIdToExecutionData1765892199653,
269
270
  _1766064542000_AddWorkflowPublishScopeToProjectRoles_1.AddWorkflowPublishScopeToProjectRoles1766064542000,
270
271
  _1766068346315_AddChatMessageIndices_1.AddChatMessageIndices1766068346315,
272
+ _1766500000000_ExpandInsightsWorkflowIdLength_1.ExpandInsightsWorkflowIdLength1766500000000,
271
273
  ];
@@ -0,0 +1,6 @@
1
+ import type { MigrationContext, ReversibleMigration } from '../migration-types';
2
+ export declare class ChangeWorkflowStatisticsFKToNoAction1767018516000 implements ReversibleMigration {
3
+ transaction: false;
4
+ up({ queryRunner, tablePrefix }: MigrationContext): Promise<void>;
5
+ down({ queryRunner, tablePrefix }: MigrationContext): Promise<void>;
6
+ }
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ChangeWorkflowStatisticsFKToNoAction1767018516000 = void 0;
4
+ class ChangeWorkflowStatisticsFKToNoAction1767018516000 {
5
+ constructor() {
6
+ this.transaction = false;
7
+ }
8
+ async up({ queryRunner, tablePrefix }) {
9
+ await queryRunner.query(`
10
+ CREATE TABLE "${tablePrefix}TMP_workflow_statistics" (
11
+ "id" INTEGER PRIMARY KEY AUTOINCREMENT,
12
+ "count" INTEGER DEFAULT 0,
13
+ "latestEvent" DATETIME,
14
+ "name" VARCHAR(128) NOT NULL,
15
+ "workflowId" VARCHAR(36) NOT NULL,
16
+ "workflowName" VARCHAR(128),
17
+ "rootCount" INTEGER DEFAULT 0
18
+ )
19
+ `);
20
+ await queryRunner.query(`
21
+ INSERT INTO "${tablePrefix}TMP_workflow_statistics" ("count", "latestEvent", "name", "workflowId", "workflowName", "rootCount")
22
+ SELECT ws."count", ws."latestEvent", ws."name", ws."workflowId", we."name", ws."rootCount"
23
+ FROM "${tablePrefix}workflow_statistics" ws
24
+ LEFT JOIN "${tablePrefix}workflow_entity" we ON ws."workflowId" = we."id"
25
+ `);
26
+ await queryRunner.query(`DROP TABLE "${tablePrefix}workflow_statistics"`);
27
+ await queryRunner.query(`ALTER TABLE "${tablePrefix}TMP_workflow_statistics" RENAME TO "${tablePrefix}workflow_statistics"`);
28
+ await queryRunner.query(`CREATE UNIQUE INDEX "IDX_${tablePrefix}workflow_statistics_workflow_name" ON "${tablePrefix}workflow_statistics" ("workflowId", "name")`);
29
+ }
30
+ async down({ queryRunner, tablePrefix }) {
31
+ await queryRunner.query(`
32
+ CREATE TABLE "${tablePrefix}TMP_workflow_statistics" (
33
+ "count" INTEGER DEFAULT 0,
34
+ "latestEvent" DATETIME,
35
+ "name" VARCHAR(128) NOT NULL,
36
+ "workflowId" VARCHAR(36) NOT NULL,
37
+ "rootCount" INTEGER DEFAULT 0,
38
+ PRIMARY KEY("workflowId", "name"),
39
+ FOREIGN KEY("workflowId") REFERENCES "${tablePrefix}workflow_entity"("id") ON DELETE CASCADE
40
+ )
41
+ `);
42
+ await queryRunner.query(`
43
+ DELETE FROM "${tablePrefix}workflow_statistics"
44
+ WHERE "workflowId" NOT IN (SELECT "id" FROM "${tablePrefix}workflow_entity")
45
+ `);
46
+ await queryRunner.query(`
47
+ INSERT INTO "${tablePrefix}TMP_workflow_statistics" ("count", "latestEvent", "name", "workflowId", "rootCount")
48
+ SELECT
49
+ "count",
50
+ "latestEvent",
51
+ "name",
52
+ "workflowId",
53
+ "rootCount"
54
+ FROM "${tablePrefix}workflow_statistics"
55
+ `);
56
+ await queryRunner.query(`DROP TABLE "${tablePrefix}workflow_statistics"`);
57
+ await queryRunner.query(`ALTER TABLE "${tablePrefix}TMP_workflow_statistics" RENAME TO "${tablePrefix}workflow_statistics"`);
58
+ }
59
+ }
60
+ exports.ChangeWorkflowStatisticsFKToNoAction1767018516000 = ChangeWorkflowStatisticsFKToNoAction1767018516000;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atom8n/db",
3
- "version": "1.4.2",
3
+ "version": "1.5.0",
4
4
  "scripts": {
5
5
  "clean": "rimraf dist .turbo",
6
6
  "dev": "pnpm watch",
@@ -22,19 +22,19 @@
22
22
  "dist/**/*"
23
23
  ],
24
24
  "dependencies": {
25
- "@n8n/api-types": "npm:@atom8n/api-types@1.4.2",
26
- "@n8n/backend-common": "npm:@atom8n/backend-common@1.4.2",
27
- "@n8n/config": "npm:@atom8n/config@2.3.2",
28
- "@n8n/constants": "npm:@atom8n/constants@0.17.2",
29
- "@n8n/decorators": "npm:@atom8n/decorators@1.4.2",
30
- "@n8n/di": "npm:@atom8n/di@0.12.2",
31
- "@n8n/permissions": "npm:@atom8n/permissions@0.47.2",
25
+ "@n8n/api-types": "npm:@atom8n/api-types@1.5.0",
26
+ "@n8n/backend-common": "npm:@atom8n/backend-common@1.5.0",
27
+ "@n8n/config": "npm:@atom8n/config@2.4.0",
28
+ "@n8n/constants": "npm:@atom8n/constants@0.18.0",
29
+ "@n8n/decorators": "npm:@atom8n/decorators@1.5.0",
30
+ "@n8n/di": "npm:@atom8n/di@0.13.0",
31
+ "@n8n/permissions": "npm:@atom8n/permissions@0.48.0",
32
32
  "@n8n/typeorm": "0.3.20-15",
33
33
  "class-validator": "0.14.0",
34
34
  "flatted": "3.2.7",
35
35
  "lodash": "4.17.21",
36
- "n8n-core": "npm:@atom8n/n8n-core@2.4.4",
37
- "n8n-workflow": "npm:@atom8n/n8n-workflow@2.4.2",
36
+ "n8n-core": "npm:@atom8n/n8n-core@2.5.0",
37
+ "n8n-workflow": "npm:@atom8n/n8n-workflow@2.5.0",
38
38
  "nanoid": "3.3.8",
39
39
  "p-lazy": "3.1.0",
40
40
  "reflect-metadata": "0.2.2",
@@ -43,7 +43,7 @@
43
43
  "zod": "3.25.67"
44
44
  },
45
45
  "devDependencies": {
46
- "@n8n/typescript-config": "npm:@atom8n/typescript-config@1.5.2",
46
+ "@n8n/typescript-config": "npm:@atom8n/typescript-config@1.6.0",
47
47
  "@types/lodash": "4.17.17",
48
48
  "express": "5.1.0"
49
49
  }