@trafficgroup/knex-rel 0.1.21 → 0.1.23-rc.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.
- package/.claude/settings.local.json +5 -2
- package/CLAUDE.md +2 -11
- package/dist/constants/folder.constants.d.ts +2 -2
- package/dist/constants/folder.constants.js +6 -15
- package/dist/constants/folder.constants.js.map +1 -1
- package/dist/constants/study.constants.d.ts +1 -1
- package/dist/constants/study.constants.js +1 -1
- package/dist/constants/video.constants.d.ts +2 -2
- package/dist/constants/video.constants.js +5 -9
- package/dist/constants/video.constants.js.map +1 -1
- package/dist/dao/VideoMinuteResultDAO.d.ts +19 -2
- package/dist/dao/VideoMinuteResultDAO.js +75 -29
- package/dist/dao/VideoMinuteResultDAO.js.map +1 -1
- package/dist/dao/auth/auth.dao.js +1 -4
- package/dist/dao/auth/auth.dao.js.map +1 -1
- package/dist/dao/batch/batch.dao.d.ts +0 -10
- package/dist/dao/batch/batch.dao.js +14 -51
- package/dist/dao/batch/batch.dao.js.map +1 -1
- package/dist/dao/camera/camera.dao.js +7 -10
- package/dist/dao/camera/camera.dao.js.map +1 -1
- package/dist/dao/chat/chat.dao.d.ts +1 -1
- package/dist/dao/chat/chat.dao.js +40 -27
- package/dist/dao/chat/chat.dao.js.map +1 -1
- package/dist/dao/folder/folder.dao.js +7 -18
- package/dist/dao/folder/folder.dao.js.map +1 -1
- package/dist/dao/location/location.dao.js +9 -16
- package/dist/dao/location/location.dao.js.map +1 -1
- package/dist/dao/message/message.dao.d.ts +1 -1
- package/dist/dao/message/message.dao.js +26 -18
- package/dist/dao/message/message.dao.js.map +1 -1
- package/dist/dao/report-configuration/report-configuration.dao.js +68 -39
- package/dist/dao/report-configuration/report-configuration.dao.js.map +1 -1
- package/dist/dao/study/study.dao.d.ts +8 -1
- package/dist/dao/study/study.dao.js +20 -15
- package/dist/dao/study/study.dao.js.map +1 -1
- package/dist/dao/systemConfiguration/SystemConfigurationDAO.d.ts +2 -2
- package/dist/dao/systemConfiguration/SystemConfigurationDAO.js +26 -26
- package/dist/dao/systemConfiguration/SystemConfigurationDAO.js.map +1 -1
- package/dist/dao/user/user.dao.js +1 -4
- package/dist/dao/user/user.dao.js.map +1 -1
- package/dist/dao/user-push-notification-token/user-push-notification-token.dao.js +8 -26
- package/dist/dao/user-push-notification-token/user-push-notification-token.dao.js.map +1 -1
- package/dist/dao/video/video.dao.js +28 -30
- package/dist/dao/video/video.dao.js.map +1 -1
- package/dist/index.d.ts +10 -9
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/interfaces/batch/batch.interfaces.d.ts +1 -1
- package/dist/interfaces/camera/camera.interfaces.d.ts +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/report-configuration/report-configuration.interfaces.d.ts +1 -0
- package/dist/interfaces/study/study.interfaces.d.ts +2 -8
- 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 +2 -2
- package/migrations/20250717160737_migration.ts +1 -1
- package/migrations/20250717160908_migration.ts +2 -5
- 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 +4 -8
- package/migrations/20250722211019_migration.ts +1 -1
- package/migrations/20250723153852_migration.ts +10 -13
- package/migrations/20250723162257_migration.ts +7 -4
- package/migrations/20250723171109_migration.ts +7 -4
- package/migrations/20250723205331_migration.ts +9 -6
- package/migrations/20250724191345_migration.ts +11 -8
- package/migrations/20250730180932_migration.ts +13 -14
- package/migrations/20250730213625_migration.ts +11 -8
- package/migrations/20250804124509_migration.ts +21 -26
- package/migrations/20250804132053_migration.ts +8 -5
- package/migrations/20250804164518_migration.ts +7 -7
- package/migrations/20250823223016_migration.ts +21 -32
- package/migrations/20250910015452_migration.ts +6 -18
- package/migrations/20250911000000_migration.ts +4 -18
- package/migrations/20250917144153_migration.ts +7 -14
- package/migrations/20250930200521_migration.ts +4 -8
- package/migrations/20251010143500_migration.ts +6 -27
- package/migrations/20251020225758_migration.ts +15 -51
- package/migrations/20251112120000_migration.ts +2 -10
- package/migrations/20251112120200_migration.ts +7 -19
- package/migrations/20251112120300_migration.ts +2 -7
- package/migrations/20260109140000_migration.ts +2 -7
- package/package.json +3 -3
- package/src/constants/folder.constants.ts +8 -17
- package/src/constants/study.constants.ts +1 -1
- package/src/constants/video.constants.ts +7 -11
- package/src/d.types.ts +14 -18
- package/src/dao/VideoMinuteResultDAO.ts +127 -83
- package/src/dao/auth/auth.dao.ts +55 -58
- package/src/dao/batch/batch.dao.ts +100 -145
- package/src/dao/camera/camera.dao.ts +121 -124
- package/src/dao/chat/chat.dao.ts +45 -45
- package/src/dao/folder/folder.dao.ts +90 -105
- package/src/dao/location/location.dao.ts +87 -109
- package/src/dao/message/message.dao.ts +32 -32
- package/src/dao/reconciliation-log/reconciliation-log.dao.ts +1 -1
- package/src/dao/report-configuration/report-configuration.dao.ts +381 -370
- package/src/dao/study/study.dao.ts +83 -94
- package/src/dao/systemConfiguration/SystemConfigurationDAO.ts +35 -41
- package/src/dao/user/user.dao.ts +50 -52
- package/src/dao/user-push-notification-token/user-push-notification-token.dao.ts +48 -80
- package/src/dao/video/video.dao.ts +345 -396
- package/src/entities/BaseEntity.ts +1 -1
- package/src/index.ts +30 -43
- package/src/interfaces/auth/auth.interfaces.ts +10 -10
- package/src/interfaces/batch/batch.interfaces.ts +1 -1
- package/src/interfaces/camera/camera.interfaces.ts +9 -9
- package/src/interfaces/chat/chat.interfaces.ts +4 -4
- package/src/interfaces/folder/folder.interfaces.ts +2 -2
- package/src/interfaces/location/location.interfaces.ts +7 -7
- package/src/interfaces/message/message.interfaces.ts +3 -3
- package/src/interfaces/report-configuration/report-configuration.interfaces.ts +17 -16
- package/src/interfaces/study/study.interfaces.ts +3 -10
- package/src/interfaces/user/user.interfaces.ts +9 -9
- package/src/interfaces/user-push-notification-token/user-push-notification-token.interfaces.ts +9 -9
- package/src/interfaces/video/video.interfaces.ts +34 -34
|
@@ -1,23 +1,17 @@
|
|
|
1
1
|
import type { IUser } from "../user/user.interfaces";
|
|
2
2
|
import type { ILocation } from "../location/location.interfaces";
|
|
3
|
-
import type { SortOrder } from "../../constants/video.constants";
|
|
4
|
-
import type { StudySortField } from "../../constants/study.constants";
|
|
5
3
|
export interface IStudy {
|
|
6
4
|
id: number;
|
|
7
5
|
uuid: string;
|
|
8
6
|
name: string;
|
|
9
7
|
description?: string;
|
|
10
|
-
type:
|
|
8
|
+
type: 'TMC' | 'ATR';
|
|
11
9
|
createdBy: number;
|
|
12
10
|
locationId?: number;
|
|
13
11
|
isMultiCamera: boolean;
|
|
14
|
-
status:
|
|
12
|
+
status: 'COMPLETE' | 'IN PROGRESS' | 'FAILED';
|
|
15
13
|
created_at: string;
|
|
16
14
|
updated_at: string;
|
|
17
15
|
user?: IUser;
|
|
18
16
|
location?: ILocation;
|
|
19
17
|
}
|
|
20
|
-
export interface IStudyFilters {
|
|
21
|
-
sortBy?: StudySortField;
|
|
22
|
-
sortOrder?: SortOrder;
|
|
23
|
-
}
|
|
@@ -14,9 +14,9 @@ export interface IVideo {
|
|
|
14
14
|
videoOutputLocation: string | null;
|
|
15
15
|
generateVideoOutput: boolean;
|
|
16
16
|
videoRate: number;
|
|
17
|
-
videoType:
|
|
17
|
+
videoType: 'TMC' | 'ATR' | 'JUNCTION' | 'ROUNDABOUT' | 'PATHWAY';
|
|
18
18
|
metadata: Record<string, any>;
|
|
19
|
-
status:
|
|
19
|
+
status: 'QUEUED' | 'PROCESSING' | 'COMPLETED' | 'FAILED' | 'PENDING';
|
|
20
20
|
progress: number;
|
|
21
21
|
remainingTime: string;
|
|
22
22
|
results: Record<string, any>;
|
|
@@ -13,10 +13,7 @@ export async function up(knex: Knex): Promise<void> {
|
|
|
13
13
|
.inTable("user")
|
|
14
14
|
.onDelete("CASCADE");
|
|
15
15
|
|
|
16
|
-
table
|
|
17
|
-
.enu("status", ["COMPLETE", "IN PROGRESS", "FAILED"])
|
|
18
|
-
.notNullable()
|
|
19
|
-
.defaultTo("IN PROGRESS");
|
|
16
|
+
table.enu("status", ["COMPLETE", "IN PROGRESS", "FAILED"]).notNullable().defaultTo("IN PROGRESS");
|
|
20
17
|
|
|
21
18
|
table.timestamps(true, true); // created_at, updated_at
|
|
22
19
|
});
|
|
@@ -24,4 +21,4 @@ export async function up(knex: Knex): Promise<void> {
|
|
|
24
21
|
|
|
25
22
|
export async function down(knex: Knex): Promise<void> {
|
|
26
23
|
await knex.schema.dropTableIfExists("study");
|
|
27
|
-
}
|
|
24
|
+
}
|
|
@@ -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,10 +1,9 @@
|
|
|
1
1
|
import type { Knex } from "knex";
|
|
2
2
|
|
|
3
|
+
|
|
3
4
|
export async function up(knex: Knex): Promise<void> {
|
|
4
5
|
// 1. Crear el tipo ENUM nativo
|
|
5
|
-
await knex.raw(
|
|
6
|
-
`CREATE TYPE "video_status" AS ENUM ('QUEUED', 'PROCESSING', 'COMPLETED', 'FAILED', 'PENDING');`,
|
|
7
|
-
);
|
|
6
|
+
await knex.raw(`CREATE TYPE "video_status" AS ENUM ('QUEUED', 'PROCESSING', 'COMPLETED', 'FAILED', 'PENDING');`);
|
|
8
7
|
|
|
9
8
|
// 2. Normalizar los valores existentes
|
|
10
9
|
await knex.raw(`
|
|
@@ -54,11 +53,8 @@ export async function down(knex: Knex): Promise<void> {
|
|
|
54
53
|
await knex.schema.alterTable("video", (table) => {
|
|
55
54
|
table.dropColumn("progress");
|
|
56
55
|
table.dropColumn("remainingTime");
|
|
57
|
-
table
|
|
58
|
-
.specificType("status", "varchar(255)")
|
|
59
|
-
.notNullable()
|
|
60
|
-
.defaultTo("QUEUED")
|
|
61
|
-
.alter();
|
|
56
|
+
table.specificType("status", "varchar(255)").notNullable().defaultTo("QUEUED").alter();
|
|
62
57
|
});
|
|
63
58
|
await knex.raw('DROP TYPE IF EXISTS "video_status";');
|
|
64
59
|
}
|
|
60
|
+
|
|
@@ -1,22 +1,19 @@
|
|
|
1
1
|
import type { Knex } from "knex";
|
|
2
2
|
|
|
3
|
+
|
|
3
4
|
export async function up(knex: Knex): Promise<void> {
|
|
4
|
-
await knex.schema.createTable(
|
|
5
|
-
table.increments(
|
|
6
|
-
table
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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();
|
|
5
|
+
await knex.schema.createTable('auth', (table) => {
|
|
6
|
+
table.increments('id').primary();
|
|
7
|
+
table.integer('userId').unsigned().notNullable().references('id').inTable('users').onDelete('CASCADE');
|
|
8
|
+
table.string('password', 255).notNullable();
|
|
9
|
+
table.boolean('twofaEnabled').notNullable().defaultTo(false);
|
|
10
|
+
table.string('twofaSecret', 255).nullable();
|
|
16
11
|
table.timestamps(true, true);
|
|
17
12
|
});
|
|
18
13
|
}
|
|
19
14
|
|
|
15
|
+
|
|
20
16
|
export async function down(knex: Knex): Promise<void> {
|
|
21
|
-
await knex.schema.dropTableIfExists(
|
|
17
|
+
await knex.schema.dropTableIfExists('auth');
|
|
22
18
|
}
|
|
19
|
+
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import type { Knex } from "knex";
|
|
2
2
|
|
|
3
|
+
|
|
3
4
|
export async function up(knex: Knex): Promise<void> {
|
|
4
|
-
await knex.schema.alterTable(
|
|
5
|
-
table.boolean(
|
|
5
|
+
await knex.schema.alterTable('video', (table) => {
|
|
6
|
+
table.boolean('generateVideoOutput').notNullable().defaultTo(false);
|
|
6
7
|
});
|
|
7
8
|
}
|
|
8
9
|
|
|
10
|
+
|
|
9
11
|
export async function down(knex: Knex): Promise<void> {
|
|
10
|
-
await knex.schema.alterTable(
|
|
11
|
-
table.dropColumn(
|
|
12
|
+
await knex.schema.alterTable('video', (table) => {
|
|
13
|
+
table.dropColumn('generateVideoOutput');
|
|
12
14
|
});
|
|
13
15
|
}
|
|
16
|
+
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import type { Knex } from "knex";
|
|
2
2
|
|
|
3
|
+
|
|
3
4
|
export async function up(knex: Knex): Promise<void> {
|
|
4
|
-
await knex.schema.alterTable(
|
|
5
|
-
table.string(
|
|
5
|
+
await knex.schema.alterTable('video', (table) => {
|
|
6
|
+
table.string('videoOutputLocation').nullable();
|
|
6
7
|
});
|
|
7
8
|
}
|
|
8
9
|
|
|
10
|
+
|
|
9
11
|
export async function down(knex: Knex): Promise<void> {
|
|
10
|
-
await knex.schema.alterTable(
|
|
11
|
-
table.dropColumn(
|
|
12
|
+
await knex.schema.alterTable('video', (table) => {
|
|
13
|
+
table.dropColumn('videoOutputLocation');
|
|
12
14
|
});
|
|
13
15
|
}
|
|
16
|
+
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import type { Knex } from "knex";
|
|
2
2
|
|
|
3
|
+
|
|
3
4
|
export async function up(knex: Knex): Promise<void> {
|
|
4
|
-
await knex.schema.alterTable(
|
|
5
|
-
table.string(
|
|
6
|
-
table.boolean(
|
|
5
|
+
await knex.schema.alterTable('auth', (table) => {
|
|
6
|
+
table.string('emailToken', 255).nullable();
|
|
7
|
+
table.boolean('emailVerified').notNullable().defaultTo(false);
|
|
7
8
|
});
|
|
8
9
|
}
|
|
9
10
|
|
|
11
|
+
|
|
10
12
|
export async function down(knex: Knex): Promise<void> {
|
|
11
|
-
await knex.schema.alterTable(
|
|
12
|
-
table.dropColumn(
|
|
13
|
-
table.dropColumn(
|
|
13
|
+
await knex.schema.alterTable('auth', (table) => {
|
|
14
|
+
table.dropColumn('emailToken');
|
|
15
|
+
table.dropColumn('emailVerified');
|
|
14
16
|
});
|
|
15
17
|
}
|
|
18
|
+
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import type { Knex } from "knex";
|
|
2
2
|
|
|
3
|
+
|
|
3
4
|
export async function up(knex: Knex): Promise<void> {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
await knex.schema.alterTable('users', (table) => {
|
|
6
|
+
table.string('profilePhoto').nullable();
|
|
7
|
+
table.string('company').nullable();
|
|
8
|
+
});
|
|
8
9
|
}
|
|
9
10
|
|
|
11
|
+
|
|
10
12
|
export async function down(knex: Knex): Promise<void> {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
await knex.schema.alterTable('users', (table) => {
|
|
14
|
+
table.dropColumn('profilePhoto');
|
|
15
|
+
table.dropColumn('company');
|
|
16
|
+
});
|
|
15
17
|
}
|
|
18
|
+
|
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
import type { Knex } from "knex";
|
|
2
2
|
|
|
3
|
+
|
|
3
4
|
export async function up(knex: Knex): Promise<void> {
|
|
4
|
-
return knex.schema.createTable(
|
|
5
|
-
table.increments(
|
|
6
|
-
table.integer(
|
|
7
|
-
table.string(
|
|
8
|
-
table.boolean(
|
|
5
|
+
return knex.schema.createTable('user_push_notification_token', (table) => {
|
|
6
|
+
table.increments('id').primary();
|
|
7
|
+
table.integer('userId').unsigned().notNullable();
|
|
8
|
+
table.string('token').notNullable();
|
|
9
|
+
table.boolean('available').defaultTo(true);
|
|
9
10
|
table.timestamps(true, true);
|
|
10
|
-
|
|
11
|
-
table
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
.inTable("users")
|
|
15
|
-
.onDelete("CASCADE");
|
|
16
|
-
table.index(["userId"]);
|
|
17
|
-
table.index(["token"]);
|
|
11
|
+
|
|
12
|
+
table.foreign('userId').references('id').inTable('users').onDelete('CASCADE');
|
|
13
|
+
table.index(['userId']);
|
|
14
|
+
table.index(['token']);
|
|
18
15
|
});
|
|
19
16
|
}
|
|
20
17
|
|
|
18
|
+
|
|
21
19
|
export async function down(knex: Knex): Promise<void> {
|
|
22
|
-
return knex.schema.dropTable(
|
|
20
|
+
return knex.schema.dropTable('user_push_notification_token');
|
|
23
21
|
}
|
|
22
|
+
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import type { Knex } from "knex";
|
|
2
2
|
|
|
3
|
+
|
|
3
4
|
export async function up(knex: Knex): Promise<void> {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
await knex.schema.alterTable('user_push_notification_token', (table) => {
|
|
6
|
+
table.string('token_type').defaultTo('expo').notNullable();
|
|
7
|
+
table.string('device_type');
|
|
8
|
+
});
|
|
8
9
|
}
|
|
9
10
|
|
|
11
|
+
|
|
10
12
|
export async function down(knex: Knex): Promise<void> {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
await knex.schema.alterTable('user_push_notification_token', (table) => {
|
|
14
|
+
table.dropColumn('token_type');
|
|
15
|
+
table.dropColumn('device_type');
|
|
16
|
+
});
|
|
15
17
|
}
|
|
18
|
+
|
|
@@ -1,48 +1,43 @@
|
|
|
1
1
|
import type { Knex } from "knex";
|
|
2
2
|
|
|
3
|
+
|
|
3
4
|
export async function up(knex: Knex): Promise<void> {
|
|
4
5
|
// Create chat table
|
|
5
|
-
await knex.schema.createTable(
|
|
6
|
-
table.increments(
|
|
7
|
-
table.integer(
|
|
8
|
-
table.string(
|
|
9
|
-
table.enum(
|
|
6
|
+
await knex.schema.createTable('chat', (table) => {
|
|
7
|
+
table.increments('id').primary();
|
|
8
|
+
table.integer('userId').unsigned().notNullable();
|
|
9
|
+
table.string('title', 255).notNullable();
|
|
10
|
+
table.enum('status', ['active', 'archived']).defaultTo('active');
|
|
10
11
|
table.timestamps(true, true);
|
|
11
12
|
|
|
12
13
|
// Foreign key
|
|
13
|
-
table
|
|
14
|
-
.foreign("userId")
|
|
15
|
-
.references("id")
|
|
16
|
-
.inTable("users")
|
|
17
|
-
.onDelete("CASCADE");
|
|
14
|
+
table.foreign('userId').references('id').inTable('users').onDelete('CASCADE');
|
|
18
15
|
|
|
19
16
|
// Indexes
|
|
20
|
-
table.index(
|
|
21
|
-
table.index(
|
|
17
|
+
table.index('userId');
|
|
18
|
+
table.index('status');
|
|
22
19
|
});
|
|
23
20
|
|
|
24
21
|
// Create message table
|
|
25
|
-
await knex.schema.createTable(
|
|
26
|
-
table.increments(
|
|
27
|
-
table.integer(
|
|
28
|
-
table.enum(
|
|
29
|
-
table.text(
|
|
22
|
+
await knex.schema.createTable('message', (table) => {
|
|
23
|
+
table.increments('id').primary();
|
|
24
|
+
table.integer('chatId').unsigned().notNullable();
|
|
25
|
+
table.enum('role', ['user', 'assistant']).notNullable();
|
|
26
|
+
table.text('content').notNullable();
|
|
30
27
|
table.timestamps(true, true);
|
|
31
28
|
|
|
32
29
|
// Foreign key
|
|
33
|
-
table
|
|
34
|
-
.foreign("chatId")
|
|
35
|
-
.references("id")
|
|
36
|
-
.inTable("chat")
|
|
37
|
-
.onDelete("CASCADE");
|
|
30
|
+
table.foreign('chatId').references('id').inTable('chat').onDelete('CASCADE');
|
|
38
31
|
|
|
39
32
|
// Indexes
|
|
40
|
-
table.index(
|
|
41
|
-
table.index(
|
|
33
|
+
table.index('chatId');
|
|
34
|
+
table.index('created_at');
|
|
42
35
|
});
|
|
43
36
|
}
|
|
44
37
|
|
|
38
|
+
|
|
45
39
|
export async function down(knex: Knex): Promise<void> {
|
|
46
|
-
await knex.schema.dropTableIfExists(
|
|
47
|
-
await knex.schema.dropTableIfExists(
|
|
40
|
+
await knex.schema.dropTableIfExists('message');
|
|
41
|
+
await knex.schema.dropTableIfExists('chat');
|
|
48
42
|
}
|
|
43
|
+
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import type { Knex } from "knex";
|
|
2
2
|
|
|
3
|
+
|
|
3
4
|
export async function up(knex: Knex): Promise<void> {
|
|
4
5
|
// Add uuid column to chat table
|
|
5
|
-
await knex.schema.alterTable(
|
|
6
|
-
table.uuid(
|
|
7
|
-
table.index(
|
|
6
|
+
await knex.schema.alterTable('chat', (table) => {
|
|
7
|
+
table.uuid('uuid').defaultTo(knex.raw('gen_random_uuid()')).notNullable();
|
|
8
|
+
table.index('uuid');
|
|
8
9
|
});
|
|
9
10
|
}
|
|
10
11
|
|
|
12
|
+
|
|
11
13
|
export async function down(knex: Knex): Promise<void> {
|
|
12
|
-
await knex.schema.alterTable(
|
|
13
|
-
table.dropColumn(
|
|
14
|
+
await knex.schema.alterTable('chat', (table) => {
|
|
15
|
+
table.dropColumn('uuid');
|
|
14
16
|
});
|
|
15
17
|
}
|
|
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
|
+
}
|
|
@@ -2,45 +2,34 @@ import type { Knex } from "knex";
|
|
|
2
2
|
|
|
3
3
|
export async function up(knex: Knex): Promise<void> {
|
|
4
4
|
// Create video_minute_results table
|
|
5
|
-
await knex.schema.createTable(
|
|
6
|
-
table.bigIncrements(
|
|
7
|
-
table
|
|
8
|
-
|
|
9
|
-
.
|
|
10
|
-
|
|
11
|
-
|
|
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();
|
|
5
|
+
await knex.schema.createTable('video_minute_results', (table) => {
|
|
6
|
+
table.bigIncrements('id').primary();
|
|
7
|
+
table.uuid('uuid').defaultTo(knex.raw('gen_random_uuid()')).notNullable().unique();
|
|
8
|
+
table.integer('video_id').unsigned().notNullable()
|
|
9
|
+
.references('id').inTable('video').onDelete('CASCADE');
|
|
10
|
+
table.integer('minute_number').notNullable();
|
|
11
|
+
table.jsonb('results').notNullable();
|
|
21
12
|
table.timestamps(true, true);
|
|
22
|
-
|
|
13
|
+
|
|
23
14
|
// Constraints
|
|
24
|
-
table.unique([
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
table.check("minute_number >= 0", [], "valid_minute_number");
|
|
28
|
-
|
|
15
|
+
table.unique(['video_id', 'minute_number'], { indexName: 'unique_video_minute' });
|
|
16
|
+
table.check('minute_number >= 0', [], 'valid_minute_number');
|
|
17
|
+
|
|
29
18
|
// Indexes
|
|
30
|
-
table.index(
|
|
31
|
-
table.index(
|
|
32
|
-
table.index(
|
|
19
|
+
table.index('video_id', 'idx_video_minute_results_video_id');
|
|
20
|
+
table.index('uuid', 'idx_video_minute_results_uuid');
|
|
21
|
+
table.index('minute_number', 'idx_video_minute_results_minute_number');
|
|
33
22
|
});
|
|
34
|
-
|
|
23
|
+
|
|
35
24
|
// Add duration_seconds to video table
|
|
36
|
-
await knex.schema.alterTable(
|
|
37
|
-
table.integer(
|
|
25
|
+
await knex.schema.alterTable('video', (table) => {
|
|
26
|
+
table.integer('duration_seconds').nullable();
|
|
38
27
|
});
|
|
39
28
|
}
|
|
40
29
|
|
|
41
30
|
export async function down(knex: Knex): Promise<void> {
|
|
42
|
-
await knex.schema.dropTableIfExists(
|
|
43
|
-
await knex.schema.alterTable(
|
|
44
|
-
table.dropColumn(
|
|
31
|
+
await knex.schema.dropTableIfExists('video_minute_results');
|
|
32
|
+
await knex.schema.alterTable('video', (table) => {
|
|
33
|
+
table.dropColumn('duration_seconds');
|
|
45
34
|
});
|
|
46
|
-
}
|
|
35
|
+
}
|
|
@@ -2,26 +2,13 @@ import type { Knex } from "knex";
|
|
|
2
2
|
|
|
3
3
|
export async function up(knex: Knex): Promise<void> {
|
|
4
4
|
await knex.schema.alterTable("video", (table) => {
|
|
5
|
-
table
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
.comment("Whether HLS streaming is enabled for this video");
|
|
9
|
-
table
|
|
10
|
-
.text("hlsPlaylist")
|
|
11
|
-
.nullable()
|
|
12
|
-
.comment("S3 path to the HLS master playlist file");
|
|
13
|
-
table
|
|
14
|
-
.decimal("videoSizeMB", 12, 2)
|
|
15
|
-
.nullable()
|
|
16
|
-
.comment("Final processed video size in MB");
|
|
5
|
+
table.boolean("isHlsEnabled").defaultTo(false).comment("Whether HLS streaming is enabled for this video");
|
|
6
|
+
table.text("hlsPlaylist").nullable().comment("S3 path to the HLS master playlist file");
|
|
7
|
+
table.decimal("videoSizeMB", 12, 2).nullable().comment("Final processed video size in MB");
|
|
17
8
|
|
|
18
|
-
table
|
|
19
|
-
.json("streamingMetadata")
|
|
20
|
-
.nullable()
|
|
21
|
-
.comment(
|
|
22
|
-
"Additional streaming metadata (quality levels, segment info, etc.)",
|
|
23
|
-
);
|
|
9
|
+
table.json("streamingMetadata").nullable().comment("Additional streaming metadata (quality levels, segment info, etc.)");
|
|
24
10
|
});
|
|
11
|
+
|
|
25
12
|
}
|
|
26
13
|
|
|
27
14
|
export async function down(knex: Knex): Promise<void> {
|
|
@@ -32,3 +19,4 @@ export async function down(knex: Knex): Promise<void> {
|
|
|
32
19
|
table.dropColumn("streamingMetadata");
|
|
33
20
|
});
|
|
34
21
|
}
|
|
22
|
+
|