@trafficgroup/knex-rel 0.0.28 → 0.0.29
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.
- package/.claude/settings.local.json +2 -5
- package/CLAUDE.md +72 -63
- package/dist/dao/VideoMinuteResultDAO.d.ts +48 -0
- package/dist/dao/VideoMinuteResultDAO.js +238 -0
- package/dist/dao/VideoMinuteResultDAO.js.map +1 -0
- package/dist/dao/auth/auth.dao.js +4 -1
- package/dist/dao/auth/auth.dao.js.map +1 -1
- package/dist/dao/chat/chat.dao.d.ts +1 -1
- package/dist/dao/chat/chat.dao.js +25 -35
- package/dist/dao/chat/chat.dao.js.map +1 -1
- package/dist/dao/folder/folder.dao.js +7 -2
- package/dist/dao/folder/folder.dao.js.map +1 -1
- package/dist/dao/message/message.dao.d.ts +1 -1
- package/dist/dao/message/message.dao.js +18 -26
- package/dist/dao/message/message.dao.js.map +1 -1
- package/dist/dao/study/study.dao.js +7 -2
- package/dist/dao/study/study.dao.js.map +1 -1
- package/dist/dao/user/user.dao.js +4 -1
- package/dist/dao/user/user.dao.js.map +1 -1
- package/dist/dao/user-push-notification-token/user-push-notification-token.dao.js +26 -8
- package/dist/dao/user-push-notification-token/user-push-notification-token.dao.js.map +1 -1
- package/dist/dao/video/video.dao.d.ts +8 -0
- package/dist/dao/video/video.dao.js +54 -7
- package/dist/dao/video/video.dao.js.map +1 -1
- package/dist/entities/BaseEntity.d.ts +4 -0
- package/dist/entities/BaseEntity.js +3 -0
- package/dist/entities/BaseEntity.js.map +1 -0
- package/dist/entities/VideoMinuteResult.d.ts +21 -0
- package/dist/entities/VideoMinuteResult.js +3 -0
- package/dist/entities/VideoMinuteResult.js.map +1 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/interfaces/chat/chat.interfaces.d.ts +3 -3
- package/dist/interfaces/folder/folder.interfaces.d.ts +1 -1
- package/dist/interfaces/message/message.interfaces.d.ts +2 -2
- package/dist/interfaces/study/study.interfaces.d.ts +1 -1
- package/dist/interfaces/user/user.interfaces.d.ts +1 -1
- package/dist/interfaces/user-push-notification-token/user-push-notification-token.interfaces.d.ts +1 -1
- package/dist/interfaces/video/video.interfaces.d.ts +3 -2
- package/migrations/20250717160737_migration.ts +1 -1
- package/migrations/20250717160908_migration.ts +5 -2
- package/migrations/20250717161310_migration.ts +1 -1
- package/migrations/20250717161406_migration.ts +3 -3
- package/migrations/20250717162431_migration.ts +1 -1
- package/migrations/20250717173228_migration.ts +2 -2
- package/migrations/20250717204731_migration.ts +1 -1
- package/migrations/20250722210109_migration.ts +8 -4
- package/migrations/20250722211019_migration.ts +1 -1
- package/migrations/20250723153852_migration.ts +13 -10
- package/migrations/20250723162257_migration.ts +4 -7
- package/migrations/20250723171109_migration.ts +4 -7
- package/migrations/20250723205331_migration.ts +6 -9
- package/migrations/20250724191345_migration.ts +8 -11
- package/migrations/20250730180932_migration.ts +14 -13
- package/migrations/20250730213625_migration.ts +8 -11
- package/migrations/20250804124509_migration.ts +26 -21
- package/migrations/20250804132053_migration.ts +5 -8
- package/migrations/20250804164518_migration.ts +7 -7
- package/migrations/20250823223016_migration.ts +46 -0
- package/package.json +47 -47
- package/plan.md +304 -0
- package/src/d.types.ts +22 -18
- package/src/dao/VideoMinuteResultDAO.ts +273 -0
- package/src/dao/auth/auth.dao.ts +58 -55
- package/src/dao/chat/chat.dao.ts +45 -43
- package/src/dao/folder/folder.dao.ts +75 -66
- package/src/dao/message/message.dao.ts +32 -32
- package/src/dao/study/study.dao.ts +75 -66
- package/src/dao/user/user.dao.ts +59 -57
- package/src/dao/user-push-notification-token/user-push-notification-token.dao.ts +83 -49
- package/src/dao/video/video.dao.ts +199 -120
- package/src/entities/BaseEntity.ts +4 -0
- package/src/entities/VideoMinuteResult.ts +24 -0
- package/src/index.ts +37 -23
- package/src/interfaces/auth/auth.interfaces.ts +10 -10
- package/src/interfaces/chat/chat.interfaces.ts +4 -4
- package/src/interfaces/folder/folder.interfaces.ts +13 -13
- package/src/interfaces/message/message.interfaces.ts +3 -3
- package/src/interfaces/study/study.interfaces.ts +12 -12
- package/src/interfaces/user/user.interfaces.ts +11 -11
- package/src/interfaces/user-push-notification-token/user-push-notification-token.interfaces.ts +9 -9
- package/src/interfaces/video/video.interfaces.ts +22 -21
|
@@ -8,12 +8,13 @@ export interface IVideo {
|
|
|
8
8
|
videoOutputLocation: string | null;
|
|
9
9
|
generateVideoOutput: boolean;
|
|
10
10
|
videoRate: number;
|
|
11
|
-
videoType:
|
|
11
|
+
videoType: "TMC" | "ATR" | "JUNCTION" | "ROUNDABOUT" | "PATHWAY";
|
|
12
12
|
metadata: Record<string, any>;
|
|
13
|
-
status:
|
|
13
|
+
status: "QUEUED" | "PROCESSING" | "COMPLETED" | "FAILED" | "PENDING";
|
|
14
14
|
progress: number;
|
|
15
15
|
remainingTime: string;
|
|
16
16
|
results: Record<string, any>;
|
|
17
|
+
durationSeconds?: number;
|
|
17
18
|
created_at: string;
|
|
18
19
|
updated_at: string;
|
|
19
20
|
folder?: IFolder;
|
|
@@ -13,7 +13,10 @@ export async function up(knex: Knex): Promise<void> {
|
|
|
13
13
|
.inTable("user")
|
|
14
14
|
.onDelete("CASCADE");
|
|
15
15
|
|
|
16
|
-
table
|
|
16
|
+
table
|
|
17
|
+
.enu("status", ["COMPLETE", "IN PROGRESS", "FAILED"])
|
|
18
|
+
.notNullable()
|
|
19
|
+
.defaultTo("IN PROGRESS");
|
|
17
20
|
|
|
18
21
|
table.timestamps(true, true); // created_at, updated_at
|
|
19
22
|
});
|
|
@@ -21,4 +24,4 @@ export async function up(knex: Knex): Promise<void> {
|
|
|
21
24
|
|
|
22
25
|
export async function down(knex: Knex): Promise<void> {
|
|
23
26
|
await knex.schema.dropTableIfExists("study");
|
|
24
|
-
}
|
|
27
|
+
}
|
|
@@ -19,13 +19,13 @@ export async function up(knex: Knex): Promise<void> {
|
|
|
19
19
|
.enu("videoType", ["TMC", "ATR", "JUNCTION", "ROUNDABOUT", "PATHWAY"])
|
|
20
20
|
.notNullable();
|
|
21
21
|
|
|
22
|
-
table.jsonb("metadata").defaultTo(
|
|
22
|
+
table.jsonb("metadata").defaultTo("{}");
|
|
23
23
|
table
|
|
24
24
|
.enu("status", ["QUEUED", "PROCESSING", "COMPLETED", "FAILED"])
|
|
25
25
|
.notNullable()
|
|
26
26
|
.defaultTo("QUEUE");
|
|
27
27
|
|
|
28
|
-
table.jsonb("results").defaultTo(
|
|
28
|
+
table.jsonb("results").defaultTo("{}");
|
|
29
29
|
|
|
30
30
|
table.timestamps(true, true);
|
|
31
31
|
});
|
|
@@ -33,4 +33,4 @@ export async function up(knex: Knex): Promise<void> {
|
|
|
33
33
|
|
|
34
34
|
export async function down(knex: Knex): Promise<void> {
|
|
35
35
|
await knex.schema.dropTableIfExists("video");
|
|
36
|
-
}
|
|
36
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { Knex } from "knex";
|
|
2
2
|
|
|
3
3
|
export async function up(knex: Knex): Promise<void> {
|
|
4
|
-
|
|
4
|
+
await knex.schema.renameTable("user", "users");
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
export async function down(knex: Knex): Promise<void> {
|
|
8
|
-
|
|
8
|
+
await knex.schema.renameTable("users", "user");
|
|
9
9
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { Knex } from "knex";
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
export async function up(knex: Knex): Promise<void> {
|
|
5
4
|
// 1. Crear el tipo ENUM nativo
|
|
6
|
-
await knex.raw(
|
|
5
|
+
await knex.raw(
|
|
6
|
+
`CREATE TYPE "video_status" AS ENUM ('QUEUED', 'PROCESSING', 'COMPLETED', 'FAILED', 'PENDING');`,
|
|
7
|
+
);
|
|
7
8
|
|
|
8
9
|
// 2. Normalizar los valores existentes
|
|
9
10
|
await knex.raw(`
|
|
@@ -53,8 +54,11 @@ export async function down(knex: Knex): Promise<void> {
|
|
|
53
54
|
await knex.schema.alterTable("video", (table) => {
|
|
54
55
|
table.dropColumn("progress");
|
|
55
56
|
table.dropColumn("remainingTime");
|
|
56
|
-
table
|
|
57
|
+
table
|
|
58
|
+
.specificType("status", "varchar(255)")
|
|
59
|
+
.notNullable()
|
|
60
|
+
.defaultTo("QUEUED")
|
|
61
|
+
.alter();
|
|
57
62
|
});
|
|
58
63
|
await knex.raw('DROP TYPE IF EXISTS "video_status";');
|
|
59
64
|
}
|
|
60
|
-
|
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
import type { Knex } from "knex";
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
export async function up(knex: Knex): Promise<void> {
|
|
5
|
-
await knex.schema.createTable(
|
|
6
|
-
table.increments(
|
|
7
|
-
table
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
await knex.schema.createTable("auth", (table) => {
|
|
5
|
+
table.increments("id").primary();
|
|
6
|
+
table
|
|
7
|
+
.integer("userId")
|
|
8
|
+
.unsigned()
|
|
9
|
+
.notNullable()
|
|
10
|
+
.references("id")
|
|
11
|
+
.inTable("users")
|
|
12
|
+
.onDelete("CASCADE");
|
|
13
|
+
table.string("password", 255).notNullable();
|
|
14
|
+
table.boolean("twofaEnabled").notNullable().defaultTo(false);
|
|
15
|
+
table.string("twofaSecret", 255).nullable();
|
|
11
16
|
table.timestamps(true, true);
|
|
12
17
|
});
|
|
13
18
|
}
|
|
14
19
|
|
|
15
|
-
|
|
16
20
|
export async function down(knex: Knex): Promise<void> {
|
|
17
|
-
await knex.schema.dropTableIfExists(
|
|
21
|
+
await knex.schema.dropTableIfExists("auth");
|
|
18
22
|
}
|
|
19
|
-
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import type { Knex } from "knex";
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
export async function up(knex: Knex): Promise<void> {
|
|
5
|
-
await knex.schema.alterTable(
|
|
6
|
-
table.boolean(
|
|
4
|
+
await knex.schema.alterTable("video", (table) => {
|
|
5
|
+
table.boolean("generateVideoOutput").notNullable().defaultTo(false);
|
|
7
6
|
});
|
|
8
7
|
}
|
|
9
8
|
|
|
10
|
-
|
|
11
9
|
export async function down(knex: Knex): Promise<void> {
|
|
12
|
-
await knex.schema.alterTable(
|
|
13
|
-
table.dropColumn(
|
|
10
|
+
await knex.schema.alterTable("video", (table) => {
|
|
11
|
+
table.dropColumn("generateVideoOutput");
|
|
14
12
|
});
|
|
15
13
|
}
|
|
16
|
-
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import type { Knex } from "knex";
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
export async function up(knex: Knex): Promise<void> {
|
|
5
|
-
await knex.schema.alterTable(
|
|
6
|
-
table.string(
|
|
4
|
+
await knex.schema.alterTable("video", (table) => {
|
|
5
|
+
table.string("videoOutputLocation").nullable();
|
|
7
6
|
});
|
|
8
7
|
}
|
|
9
8
|
|
|
10
|
-
|
|
11
9
|
export async function down(knex: Knex): Promise<void> {
|
|
12
|
-
await knex.schema.alterTable(
|
|
13
|
-
table.dropColumn(
|
|
10
|
+
await knex.schema.alterTable("video", (table) => {
|
|
11
|
+
table.dropColumn("videoOutputLocation");
|
|
14
12
|
});
|
|
15
13
|
}
|
|
16
|
-
|
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
import type { Knex } from "knex";
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
export async function up(knex: Knex): Promise<void> {
|
|
5
|
-
await knex.schema.alterTable(
|
|
6
|
-
table.string(
|
|
7
|
-
table.boolean(
|
|
4
|
+
await knex.schema.alterTable("auth", (table) => {
|
|
5
|
+
table.string("emailToken", 255).nullable();
|
|
6
|
+
table.boolean("emailVerified").notNullable().defaultTo(false);
|
|
8
7
|
});
|
|
9
8
|
}
|
|
10
9
|
|
|
11
|
-
|
|
12
10
|
export async function down(knex: Knex): Promise<void> {
|
|
13
|
-
await knex.schema.alterTable(
|
|
14
|
-
table.dropColumn(
|
|
15
|
-
table.dropColumn(
|
|
11
|
+
await knex.schema.alterTable("auth", (table) => {
|
|
12
|
+
table.dropColumn("emailToken");
|
|
13
|
+
table.dropColumn("emailVerified");
|
|
16
14
|
});
|
|
17
15
|
}
|
|
18
|
-
|
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
import type { Knex } from "knex";
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
export async function up(knex: Knex): Promise<void> {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
await knex.schema.alterTable("users", (table) => {
|
|
5
|
+
table.string("profilePhoto").nullable();
|
|
6
|
+
table.string("company").nullable();
|
|
7
|
+
});
|
|
9
8
|
}
|
|
10
9
|
|
|
11
|
-
|
|
12
10
|
export async function down(knex: Knex): Promise<void> {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
await knex.schema.alterTable("users", (table) => {
|
|
12
|
+
table.dropColumn("profilePhoto");
|
|
13
|
+
table.dropColumn("company");
|
|
14
|
+
});
|
|
17
15
|
}
|
|
18
|
-
|
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
import type { Knex } from "knex";
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
export async function up(knex: Knex): Promise<void> {
|
|
5
|
-
return knex.schema.createTable(
|
|
6
|
-
table.increments(
|
|
7
|
-
table.integer(
|
|
8
|
-
table.string(
|
|
9
|
-
table.boolean(
|
|
4
|
+
return knex.schema.createTable("user_push_notification_token", (table) => {
|
|
5
|
+
table.increments("id").primary();
|
|
6
|
+
table.integer("userId").unsigned().notNullable();
|
|
7
|
+
table.string("token").notNullable();
|
|
8
|
+
table.boolean("available").defaultTo(true);
|
|
10
9
|
table.timestamps(true, true);
|
|
11
|
-
|
|
12
|
-
table
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
|
|
11
|
+
table
|
|
12
|
+
.foreign("userId")
|
|
13
|
+
.references("id")
|
|
14
|
+
.inTable("users")
|
|
15
|
+
.onDelete("CASCADE");
|
|
16
|
+
table.index(["userId"]);
|
|
17
|
+
table.index(["token"]);
|
|
15
18
|
});
|
|
16
19
|
}
|
|
17
20
|
|
|
18
|
-
|
|
19
21
|
export async function down(knex: Knex): Promise<void> {
|
|
20
|
-
return knex.schema.dropTable(
|
|
22
|
+
return knex.schema.dropTable("user_push_notification_token");
|
|
21
23
|
}
|
|
22
|
-
|
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
import type { Knex } from "knex";
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
export async function up(knex: Knex): Promise<void> {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
await knex.schema.alterTable("user_push_notification_token", (table) => {
|
|
5
|
+
table.string("token_type").defaultTo("expo").notNullable();
|
|
6
|
+
table.string("device_type");
|
|
7
|
+
});
|
|
9
8
|
}
|
|
10
9
|
|
|
11
|
-
|
|
12
10
|
export async function down(knex: Knex): Promise<void> {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
await knex.schema.alterTable("user_push_notification_token", (table) => {
|
|
12
|
+
table.dropColumn("token_type");
|
|
13
|
+
table.dropColumn("device_type");
|
|
14
|
+
});
|
|
17
15
|
}
|
|
18
|
-
|
|
@@ -1,43 +1,48 @@
|
|
|
1
1
|
import type { Knex } from "knex";
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
export async function up(knex: Knex): Promise<void> {
|
|
5
4
|
// Create chat table
|
|
6
|
-
await knex.schema.createTable(
|
|
7
|
-
table.increments(
|
|
8
|
-
table.integer(
|
|
9
|
-
table.string(
|
|
10
|
-
table.enum(
|
|
5
|
+
await knex.schema.createTable("chat", (table) => {
|
|
6
|
+
table.increments("id").primary();
|
|
7
|
+
table.integer("userId").unsigned().notNullable();
|
|
8
|
+
table.string("title", 255).notNullable();
|
|
9
|
+
table.enum("status", ["active", "archived"]).defaultTo("active");
|
|
11
10
|
table.timestamps(true, true);
|
|
12
11
|
|
|
13
12
|
// Foreign key
|
|
14
|
-
table
|
|
13
|
+
table
|
|
14
|
+
.foreign("userId")
|
|
15
|
+
.references("id")
|
|
16
|
+
.inTable("users")
|
|
17
|
+
.onDelete("CASCADE");
|
|
15
18
|
|
|
16
19
|
// Indexes
|
|
17
|
-
table.index(
|
|
18
|
-
table.index(
|
|
20
|
+
table.index("userId");
|
|
21
|
+
table.index("status");
|
|
19
22
|
});
|
|
20
23
|
|
|
21
24
|
// Create message table
|
|
22
|
-
await knex.schema.createTable(
|
|
23
|
-
table.increments(
|
|
24
|
-
table.integer(
|
|
25
|
-
table.enum(
|
|
26
|
-
table.text(
|
|
25
|
+
await knex.schema.createTable("message", (table) => {
|
|
26
|
+
table.increments("id").primary();
|
|
27
|
+
table.integer("chatId").unsigned().notNullable();
|
|
28
|
+
table.enum("role", ["user", "assistant"]).notNullable();
|
|
29
|
+
table.text("content").notNullable();
|
|
27
30
|
table.timestamps(true, true);
|
|
28
31
|
|
|
29
32
|
// Foreign key
|
|
30
|
-
table
|
|
33
|
+
table
|
|
34
|
+
.foreign("chatId")
|
|
35
|
+
.references("id")
|
|
36
|
+
.inTable("chat")
|
|
37
|
+
.onDelete("CASCADE");
|
|
31
38
|
|
|
32
39
|
// Indexes
|
|
33
|
-
table.index(
|
|
34
|
-
table.index(
|
|
40
|
+
table.index("chatId");
|
|
41
|
+
table.index("created_at");
|
|
35
42
|
});
|
|
36
43
|
}
|
|
37
44
|
|
|
38
|
-
|
|
39
45
|
export async function down(knex: Knex): Promise<void> {
|
|
40
|
-
await knex.schema.dropTableIfExists(
|
|
41
|
-
await knex.schema.dropTableIfExists(
|
|
46
|
+
await knex.schema.dropTableIfExists("message");
|
|
47
|
+
await knex.schema.dropTableIfExists("chat");
|
|
42
48
|
}
|
|
43
|
-
|
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
import type { Knex } from "knex";
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
export async function up(knex: Knex): Promise<void> {
|
|
5
4
|
// Add uuid column to chat table
|
|
6
|
-
await knex.schema.alterTable(
|
|
7
|
-
table.uuid(
|
|
8
|
-
table.index(
|
|
5
|
+
await knex.schema.alterTable("chat", (table) => {
|
|
6
|
+
table.uuid("uuid").defaultTo(knex.raw("gen_random_uuid()")).notNullable();
|
|
7
|
+
table.index("uuid");
|
|
9
8
|
});
|
|
10
9
|
}
|
|
11
10
|
|
|
12
|
-
|
|
13
11
|
export async function down(knex: Knex): Promise<void> {
|
|
14
|
-
await knex.schema.alterTable(
|
|
15
|
-
table.dropColumn(
|
|
12
|
+
await knex.schema.alterTable("chat", (table) => {
|
|
13
|
+
table.dropColumn("uuid");
|
|
16
14
|
});
|
|
17
15
|
}
|
|
18
|
-
|
|
@@ -2,16 +2,16 @@ import type { Knex } from "knex";
|
|
|
2
2
|
|
|
3
3
|
export async function up(knex: Knex): Promise<void> {
|
|
4
4
|
// Add description and type columns to study table
|
|
5
|
-
await knex.schema.alterTable(
|
|
6
|
-
table.text(
|
|
7
|
-
table.string(
|
|
5
|
+
await knex.schema.alterTable("study", (table) => {
|
|
6
|
+
table.text("description").nullable();
|
|
7
|
+
table.string("type", 50).notNullable().defaultTo("TMC");
|
|
8
8
|
});
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export async function down(knex: Knex): Promise<void> {
|
|
12
12
|
// Remove description and type columns from study table
|
|
13
|
-
await knex.schema.alterTable(
|
|
14
|
-
table.dropColumn(
|
|
15
|
-
table.dropColumn(
|
|
13
|
+
await knex.schema.alterTable("study", (table) => {
|
|
14
|
+
table.dropColumn("description");
|
|
15
|
+
table.dropColumn("type");
|
|
16
16
|
});
|
|
17
|
-
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { Knex } from "knex";
|
|
2
|
+
|
|
3
|
+
export async function up(knex: Knex): Promise<void> {
|
|
4
|
+
// Create video_minute_results table
|
|
5
|
+
await knex.schema.createTable("video_minute_results", (table) => {
|
|
6
|
+
table.bigIncrements("id").primary();
|
|
7
|
+
table
|
|
8
|
+
.uuid("uuid")
|
|
9
|
+
.defaultTo(knex.raw("gen_random_uuid()"))
|
|
10
|
+
.notNullable()
|
|
11
|
+
.unique();
|
|
12
|
+
table
|
|
13
|
+
.integer("video_id")
|
|
14
|
+
.unsigned()
|
|
15
|
+
.notNullable()
|
|
16
|
+
.references("id")
|
|
17
|
+
.inTable("video")
|
|
18
|
+
.onDelete("CASCADE");
|
|
19
|
+
table.integer("minute_number").notNullable();
|
|
20
|
+
table.jsonb("results").notNullable();
|
|
21
|
+
table.timestamps(true, true);
|
|
22
|
+
|
|
23
|
+
// Constraints
|
|
24
|
+
table.unique(["video_id", "minute_number"], {
|
|
25
|
+
indexName: "unique_video_minute",
|
|
26
|
+
});
|
|
27
|
+
table.check("minute_number >= 0", [], "valid_minute_number");
|
|
28
|
+
|
|
29
|
+
// Indexes
|
|
30
|
+
table.index("video_id", "idx_video_minute_results_video_id");
|
|
31
|
+
table.index("uuid", "idx_video_minute_results_uuid");
|
|
32
|
+
table.index("minute_number", "idx_video_minute_results_minute_number");
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
// Add duration_seconds to video table
|
|
36
|
+
await knex.schema.alterTable("video", (table) => {
|
|
37
|
+
table.integer("duration_seconds").nullable();
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export async function down(knex: Knex): Promise<void> {
|
|
42
|
+
await knex.schema.dropTableIfExists("video_minute_results");
|
|
43
|
+
await knex.schema.alterTable("video", (table) => {
|
|
44
|
+
table.dropColumn("duration_seconds");
|
|
45
|
+
});
|
|
46
|
+
}
|
package/package.json
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@trafficgroup/knex-rel",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "Knex Module",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "jest",
|
|
8
|
-
"format": "prettier --write .",
|
|
9
|
-
"build": "tsc",
|
|
10
|
-
"clean": "rimraf dist && npm run format && npm run build",
|
|
11
|
-
"npm:publish": "npm run clean && npm publish",
|
|
12
|
-
"migrate:create": "knex migrate:make migration -x ts",
|
|
13
|
-
"migrate:deploy": "knex migrate:latest",
|
|
14
|
-
"seed:create": "knex seed:make seed -x ts",
|
|
15
|
-
"seed:run": "knex seed:run"
|
|
16
|
-
},
|
|
17
|
-
"repository": {
|
|
18
|
-
"type": "git",
|
|
19
|
-
"url": "git+https://github.com/thetrafficgroup/knex-rel.git"
|
|
20
|
-
},
|
|
21
|
-
"author": "Genium, Inc",
|
|
22
|
-
"license": "ISC",
|
|
23
|
-
"bugs": {
|
|
24
|
-
"url": "https://github.com/thetrafficgroup/knex-rel/issues"
|
|
25
|
-
},
|
|
26
|
-
"homepage": "https://github.com/thetrafficgroup/knex-rel#readme",
|
|
27
|
-
"devDependencies": {
|
|
28
|
-
"@eslint/js": "^9.23.0",
|
|
29
|
-
"@types/dotenv": "^6.1.1",
|
|
30
|
-
"@types/lodash": "^4.17.20",
|
|
31
|
-
"@types/node": "^22.13.13",
|
|
32
|
-
"eslint": "^9.23.0",
|
|
33
|
-
"globals": "^16.0.0",
|
|
34
|
-
"prettier": "^3.5.3",
|
|
35
|
-
"rimraf": "^6.0.1",
|
|
36
|
-
"ts-node": "^10.9.2",
|
|
37
|
-
"typescript": "^5.8.2",
|
|
38
|
-
"typescript-eslint": "^8.28.0"
|
|
39
|
-
},
|
|
40
|
-
"dependencies": {
|
|
41
|
-
"dotenv": "^16.4.7",
|
|
42
|
-
"knex": "^3.1.0",
|
|
43
|
-
"lodash": "^4.17.21",
|
|
44
|
-
"pg": "^8.14.1",
|
|
45
|
-
"uuid": "^11.1.0"
|
|
46
|
-
}
|
|
47
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@trafficgroup/knex-rel",
|
|
3
|
+
"version": "0.0.29",
|
|
4
|
+
"description": "Knex Module",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "jest",
|
|
8
|
+
"format": "prettier --write .",
|
|
9
|
+
"build": "tsc",
|
|
10
|
+
"clean": "rimraf dist && npm run format && npm run build",
|
|
11
|
+
"npm:publish": "npm run clean && npm publish",
|
|
12
|
+
"migrate:create": "knex migrate:make migration -x ts",
|
|
13
|
+
"migrate:deploy": "knex migrate:latest",
|
|
14
|
+
"seed:create": "knex seed:make seed -x ts",
|
|
15
|
+
"seed:run": "knex seed:run"
|
|
16
|
+
},
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/thetrafficgroup/knex-rel.git"
|
|
20
|
+
},
|
|
21
|
+
"author": "Genium, Inc",
|
|
22
|
+
"license": "ISC",
|
|
23
|
+
"bugs": {
|
|
24
|
+
"url": "https://github.com/thetrafficgroup/knex-rel/issues"
|
|
25
|
+
},
|
|
26
|
+
"homepage": "https://github.com/thetrafficgroup/knex-rel#readme",
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@eslint/js": "^9.23.0",
|
|
29
|
+
"@types/dotenv": "^6.1.1",
|
|
30
|
+
"@types/lodash": "^4.17.20",
|
|
31
|
+
"@types/node": "^22.13.13",
|
|
32
|
+
"eslint": "^9.23.0",
|
|
33
|
+
"globals": "^16.0.0",
|
|
34
|
+
"prettier": "^3.5.3",
|
|
35
|
+
"rimraf": "^6.0.1",
|
|
36
|
+
"ts-node": "^10.9.2",
|
|
37
|
+
"typescript": "^5.8.2",
|
|
38
|
+
"typescript-eslint": "^8.28.0"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"dotenv": "^16.4.7",
|
|
42
|
+
"knex": "^3.1.0",
|
|
43
|
+
"lodash": "^4.17.21",
|
|
44
|
+
"pg": "^8.14.1",
|
|
45
|
+
"uuid": "^11.1.0"
|
|
46
|
+
}
|
|
47
|
+
}
|