@trafficgroup/knex-rel 0.1.11 → 0.1.12

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.
Files changed (110) hide show
  1. package/.claude/settings.local.json +2 -5
  2. package/CLAUDE.md +11 -2
  3. package/dist/constants/folder.constants.d.ts +12 -0
  4. package/dist/constants/folder.constants.js +28 -0
  5. package/dist/constants/folder.constants.js.map +1 -0
  6. package/dist/constants/video.constants.d.ts +2 -2
  7. package/dist/constants/video.constants.js +9 -5
  8. package/dist/constants/video.constants.js.map +1 -1
  9. package/dist/dao/VideoMinuteResultDAO.d.ts +1 -1
  10. package/dist/dao/VideoMinuteResultDAO.js +29 -23
  11. package/dist/dao/VideoMinuteResultDAO.js.map +1 -1
  12. package/dist/dao/auth/auth.dao.js +4 -1
  13. package/dist/dao/auth/auth.dao.js.map +1 -1
  14. package/dist/dao/batch/batch.dao.js +13 -14
  15. package/dist/dao/batch/batch.dao.js.map +1 -1
  16. package/dist/dao/camera/camera.dao.js +10 -7
  17. package/dist/dao/camera/camera.dao.js.map +1 -1
  18. package/dist/dao/chat/chat.dao.d.ts +1 -1
  19. package/dist/dao/chat/chat.dao.js +27 -40
  20. package/dist/dao/chat/chat.dao.js.map +1 -1
  21. package/dist/dao/folder/folder.dao.d.ts +10 -1
  22. package/dist/dao/folder/folder.dao.js +44 -6
  23. package/dist/dao/folder/folder.dao.js.map +1 -1
  24. package/dist/dao/location/location.dao.js +16 -9
  25. package/dist/dao/location/location.dao.js.map +1 -1
  26. package/dist/dao/message/message.dao.d.ts +1 -1
  27. package/dist/dao/message/message.dao.js +18 -26
  28. package/dist/dao/message/message.dao.js.map +1 -1
  29. package/dist/dao/report-configuration/report-configuration.dao.js +32 -31
  30. package/dist/dao/report-configuration/report-configuration.dao.js.map +1 -1
  31. package/dist/dao/study/study.dao.js +7 -2
  32. package/dist/dao/study/study.dao.js.map +1 -1
  33. package/dist/dao/user/user.dao.js +4 -1
  34. package/dist/dao/user/user.dao.js.map +1 -1
  35. package/dist/dao/user-push-notification-token/user-push-notification-token.dao.js +26 -8
  36. package/dist/dao/user-push-notification-token/user-push-notification-token.dao.js.map +1 -1
  37. package/dist/dao/video/video.dao.js +30 -28
  38. package/dist/dao/video/video.dao.js.map +1 -1
  39. package/dist/index.d.ts +8 -5
  40. package/dist/index.js +5 -1
  41. package/dist/index.js.map +1 -1
  42. package/dist/interfaces/batch/batch.interfaces.d.ts +1 -1
  43. package/dist/interfaces/camera/camera.interfaces.d.ts +1 -1
  44. package/dist/interfaces/chat/chat.interfaces.d.ts +3 -3
  45. package/dist/interfaces/folder/folder.interfaces.d.ts +1 -1
  46. package/dist/interfaces/message/message.interfaces.d.ts +2 -2
  47. package/dist/interfaces/study/study.interfaces.d.ts +2 -2
  48. package/dist/interfaces/user/user.interfaces.d.ts +1 -1
  49. package/dist/interfaces/user-push-notification-token/user-push-notification-token.interfaces.d.ts +1 -1
  50. package/dist/interfaces/video/video.interfaces.d.ts +2 -2
  51. package/migrations/20250717160737_migration.ts +1 -1
  52. package/migrations/20250717160908_migration.ts +5 -2
  53. package/migrations/20250717161310_migration.ts +1 -1
  54. package/migrations/20250717161406_migration.ts +3 -3
  55. package/migrations/20250717162431_migration.ts +1 -1
  56. package/migrations/20250717173228_migration.ts +2 -2
  57. package/migrations/20250717204731_migration.ts +1 -1
  58. package/migrations/20250722210109_migration.ts +8 -4
  59. package/migrations/20250722211019_migration.ts +1 -1
  60. package/migrations/20250723153852_migration.ts +13 -10
  61. package/migrations/20250723162257_migration.ts +4 -7
  62. package/migrations/20250723171109_migration.ts +4 -7
  63. package/migrations/20250723205331_migration.ts +6 -9
  64. package/migrations/20250724191345_migration.ts +8 -11
  65. package/migrations/20250730180932_migration.ts +14 -13
  66. package/migrations/20250730213625_migration.ts +8 -11
  67. package/migrations/20250804124509_migration.ts +26 -21
  68. package/migrations/20250804132053_migration.ts +5 -8
  69. package/migrations/20250804164518_migration.ts +7 -7
  70. package/migrations/20250823223016_migration.ts +32 -21
  71. package/migrations/20250910015452_migration.ts +18 -6
  72. package/migrations/20250911000000_migration.ts +18 -4
  73. package/migrations/20250917144153_migration.ts +14 -7
  74. package/migrations/20250930200521_migration.ts +8 -4
  75. package/migrations/20251010143500_migration.ts +27 -6
  76. package/migrations/20251020225758_migration.ts +51 -15
  77. package/migrations/20251112120000_migration.ts +10 -2
  78. package/migrations/20251112120200_migration.ts +19 -7
  79. package/migrations/20251112120300_migration.ts +7 -2
  80. package/package.json +1 -1
  81. package/src/constants/folder.constants.ts +29 -0
  82. package/src/constants/video.constants.ts +11 -7
  83. package/src/d.types.ts +18 -14
  84. package/src/dao/VideoMinuteResultDAO.ts +72 -49
  85. package/src/dao/auth/auth.dao.ts +58 -55
  86. package/src/dao/batch/batch.dao.ts +101 -98
  87. package/src/dao/camera/camera.dao.ts +124 -121
  88. package/src/dao/chat/chat.dao.ts +45 -45
  89. package/src/dao/folder/folder.dao.ts +112 -55
  90. package/src/dao/location/location.dao.ts +109 -87
  91. package/src/dao/message/message.dao.ts +32 -32
  92. package/src/dao/report-configuration/report-configuration.dao.ts +370 -342
  93. package/src/dao/study/study.dao.ts +88 -63
  94. package/src/dao/user/user.dao.ts +52 -50
  95. package/src/dao/user-push-notification-token/user-push-notification-token.dao.ts +80 -48
  96. package/src/dao/video/video.dao.ts +385 -334
  97. package/src/entities/BaseEntity.ts +1 -1
  98. package/src/index.ts +42 -17
  99. package/src/interfaces/auth/auth.interfaces.ts +10 -10
  100. package/src/interfaces/batch/batch.interfaces.ts +1 -1
  101. package/src/interfaces/camera/camera.interfaces.ts +9 -9
  102. package/src/interfaces/chat/chat.interfaces.ts +4 -4
  103. package/src/interfaces/folder/folder.interfaces.ts +2 -2
  104. package/src/interfaces/location/location.interfaces.ts +7 -7
  105. package/src/interfaces/message/message.interfaces.ts +3 -3
  106. package/src/interfaces/report-configuration/report-configuration.interfaces.ts +16 -16
  107. package/src/interfaces/study/study.interfaces.ts +3 -3
  108. package/src/interfaces/user/user.interfaces.ts +9 -9
  109. package/src/interfaces/user-push-notification-token/user-push-notification-token.interfaces.ts +9 -9
  110. package/src/interfaces/video/video.interfaces.ts +34 -34
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.KnexManager = exports.VIDEO_SORT_COLUMN_MAP = exports.VALID_SORT_ORDERS = exports.VALID_VIDEO_SORT_FIELDS = exports.VideoMinuteResultDAO = exports.VideoDAO = exports.UserPushNotificationTokenDAO = exports.UserDAO = exports.StudyDAO = exports.ReportConfigurationDAO = exports.MessageDAO = exports.LocationDAO = exports.FolderDAO = exports.ChatDAO = exports.CameraDAO = exports.BatchDAO = exports.AuthDAO = void 0;
6
+ exports.KnexManager = exports.FOLDER_SORT_COLUMN_MAP = exports.VALID_FOLDER_STATUSES = exports.VALID_FOLDER_SORT_FIELDS = exports.VIDEO_SORT_COLUMN_MAP = exports.VALID_SORT_ORDERS = exports.VALID_VIDEO_SORT_FIELDS = exports.VideoMinuteResultDAO = exports.VideoDAO = exports.UserPushNotificationTokenDAO = exports.UserDAO = exports.StudyDAO = exports.ReportConfigurationDAO = exports.MessageDAO = exports.LocationDAO = exports.FolderDAO = exports.ChatDAO = exports.CameraDAO = exports.BatchDAO = exports.AuthDAO = void 0;
7
7
  // DAOs
8
8
  var auth_dao_1 = require("./dao/auth/auth.dao");
9
9
  Object.defineProperty(exports, "AuthDAO", { enumerable: true, get: function () { return auth_dao_1.AuthDAO; } });
@@ -36,6 +36,10 @@ var video_constants_1 = require("./constants/video.constants");
36
36
  Object.defineProperty(exports, "VALID_VIDEO_SORT_FIELDS", { enumerable: true, get: function () { return video_constants_1.VALID_VIDEO_SORT_FIELDS; } });
37
37
  Object.defineProperty(exports, "VALID_SORT_ORDERS", { enumerable: true, get: function () { return video_constants_1.VALID_SORT_ORDERS; } });
38
38
  Object.defineProperty(exports, "VIDEO_SORT_COLUMN_MAP", { enumerable: true, get: function () { return video_constants_1.VIDEO_SORT_COLUMN_MAP; } });
39
+ var folder_constants_1 = require("./constants/folder.constants");
40
+ Object.defineProperty(exports, "VALID_FOLDER_SORT_FIELDS", { enumerable: true, get: function () { return folder_constants_1.VALID_FOLDER_SORT_FIELDS; } });
41
+ Object.defineProperty(exports, "VALID_FOLDER_STATUSES", { enumerable: true, get: function () { return folder_constants_1.VALID_FOLDER_STATUSES; } });
42
+ Object.defineProperty(exports, "FOLDER_SORT_COLUMN_MAP", { enumerable: true, get: function () { return folder_constants_1.FOLDER_SORT_COLUMN_MAP; } });
39
43
  const KnexConnection_1 = __importDefault(require("./KnexConnection"));
40
44
  exports.KnexManager = KnexConnection_1.default;
41
45
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO;AACP,gDAA8C;AAArC,mGAAA,OAAO,OAAA;AAChB,mDAAiD;AAAxC,qGAAA,QAAQ,OAAA;AACjB,sDAAoD;AAA3C,uGAAA,SAAS,OAAA;AAClB,gDAAsE;AAA7D,mGAAA,OAAO,OAAA;AAChB,sDAAoD;AAA3C,uGAAA,SAAS,OAAA;AAClB,4DAA0D;AAAjD,2GAAA,WAAW,OAAA;AACpB,yDAAuD;AAA9C,yGAAA,UAAU,OAAA;AACnB,gGAA6F;AAApF,kIAAA,sBAAsB,OAAA;AAC/B,mDAAiD;AAAxC,qGAAA,QAAQ,OAAA;AACjB,gDAA8C;AAArC,mGAAA,OAAO,OAAA;AAChB,wHAAmH;AAA1G,gJAAA,4BAA4B,OAAA;AACrC,mDAAiD;AAAxC,qGAAA,QAAQ,OAAA;AACjB,mEAAkE;AAAzD,4HAAA,oBAAoB,OAAA;AAE7B,YAAY;AACZ,+DAIqC;AAHjC,0HAAA,uBAAuB,OAAA;AACvB,oHAAA,iBAAiB,OAAA;AACjB,wHAAA,qBAAqB,OAAA;AAkCzB,sEAA2C;AAClC,sBADF,wBAAW,CACE"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO;AACP,gDAA8C;AAArC,mGAAA,OAAO,OAAA;AAChB,mDAAiD;AAAxC,qGAAA,QAAQ,OAAA;AACjB,sDAAoD;AAA3C,uGAAA,SAAS,OAAA;AAClB,gDAAsE;AAA7D,mGAAA,OAAO,OAAA;AAChB,sDAAoD;AAA3C,uGAAA,SAAS,OAAA;AAClB,4DAA0D;AAAjD,2GAAA,WAAW,OAAA;AACpB,yDAAuD;AAA9C,yGAAA,UAAU,OAAA;AACnB,gGAA6F;AAApF,kIAAA,sBAAsB,OAAA;AAC/B,mDAAiD;AAAxC,qGAAA,QAAQ,OAAA;AACjB,gDAA8C;AAArC,mGAAA,OAAO,OAAA;AAChB,wHAAmH;AAA1G,gJAAA,4BAA4B,OAAA;AACrC,mDAAiD;AAAxC,qGAAA,QAAQ,OAAA;AACjB,mEAAkE;AAAzD,4HAAA,oBAAoB,OAAA;AAE7B,YAAY;AACZ,+DAIqC;AAHnC,0HAAA,uBAAuB,OAAA;AACvB,oHAAA,iBAAiB,OAAA;AACjB,wHAAA,qBAAqB,OAAA;AAIvB,iEAIsC;AAHpC,4HAAA,wBAAwB,OAAA;AACxB,yHAAA,qBAAqB,OAAA;AACrB,0HAAA,sBAAsB,OAAA;AAoDxB,sEAA2C;AAClC,sBADF,wBAAW,CACE"}
@@ -3,7 +3,7 @@ export interface IBatch {
3
3
  id: number;
4
4
  uuid: string;
5
5
  folderId: number;
6
- status: 'PENDING' | 'IN_PROGRESS' | 'COMPLETED' | 'FAILED';
6
+ status: "PENDING" | "IN_PROGRESS" | "COMPLETED" | "FAILED";
7
7
  totalVideos: number;
8
8
  completedVideos: number;
9
9
  failedVideos: number;
@@ -4,7 +4,7 @@ export interface ICamera {
4
4
  locationId: number;
5
5
  name: string;
6
6
  description?: string;
7
- status: 'ACTIVE' | 'INACTIVE' | 'MAINTENANCE';
7
+ status: "ACTIVE" | "INACTIVE" | "MAINTENANCE";
8
8
  metadata: Record<string, any>;
9
9
  created_at: string;
10
10
  updated_at: string;
@@ -3,16 +3,16 @@ export interface IChat {
3
3
  uuid?: string;
4
4
  userId: number;
5
5
  title: string;
6
- status?: 'active' | 'archived';
6
+ status?: "active" | "archived";
7
7
  created_at?: Date;
8
8
  updated_at?: Date;
9
9
  }
10
10
  export interface IChatCreate {
11
11
  userId: number;
12
12
  title: string;
13
- status?: 'active' | 'archived';
13
+ status?: "active" | "archived";
14
14
  }
15
15
  export interface IChatUpdate {
16
16
  title?: string;
17
- status?: 'active' | 'archived';
17
+ status?: "active" | "archived";
18
18
  }
@@ -4,7 +4,7 @@ export interface IFolder {
4
4
  uuid: string;
5
5
  name: string;
6
6
  createdBy: number;
7
- status: 'UPLOADING' | 'COMPLETE';
7
+ status: "UPLOADING" | "COMPLETE";
8
8
  studyId: number;
9
9
  created_at: string;
10
10
  updated_at: string;
@@ -1,14 +1,14 @@
1
1
  export interface IMessage {
2
2
  id?: number;
3
3
  chatId: number;
4
- role: 'user' | 'assistant';
4
+ role: "user" | "assistant";
5
5
  content: string;
6
6
  created_at?: Date;
7
7
  updated_at?: Date;
8
8
  }
9
9
  export interface IMessageCreate {
10
10
  chatId: number;
11
- role: 'user' | 'assistant';
11
+ role: "user" | "assistant";
12
12
  content: string;
13
13
  }
14
14
  export interface IMessageUpdate {
@@ -5,11 +5,11 @@ export interface IStudy {
5
5
  uuid: string;
6
6
  name: string;
7
7
  description?: string;
8
- type: 'TMC' | 'ATR';
8
+ type: "TMC" | "ATR";
9
9
  createdBy: number;
10
10
  locationId?: number;
11
11
  isMultiCamera: boolean;
12
- status: 'COMPLETE' | 'IN PROGRESS' | 'FAILED';
12
+ status: "COMPLETE" | "IN PROGRESS" | "FAILED";
13
13
  created_at: string;
14
14
  updated_at: string;
15
15
  user?: IUser;
@@ -3,7 +3,7 @@ export interface IUser {
3
3
  uuid: string;
4
4
  email: string;
5
5
  nombre: string;
6
- role: 'ADMIN' | 'USER';
6
+ role: "ADMIN" | "USER";
7
7
  profilePhoto?: string;
8
8
  company?: string;
9
9
  created_at: string;
@@ -3,7 +3,7 @@ export interface IUserPushNotificationToken {
3
3
  userId: number;
4
4
  token: string;
5
5
  available: boolean;
6
- token_type: 'expo' | 'native';
6
+ token_type: "expo" | "native";
7
7
  device_type?: string;
8
8
  created_at: string;
9
9
  updated_at: string;
@@ -14,9 +14,9 @@ export interface IVideo {
14
14
  videoOutputLocation: string | null;
15
15
  generateVideoOutput: boolean;
16
16
  videoRate: number;
17
- videoType: 'TMC' | 'ATR' | 'JUNCTION' | 'ROUNDABOUT' | 'PATHWAY';
17
+ videoType: "TMC" | "ATR" | "JUNCTION" | "ROUNDABOUT" | "PATHWAY";
18
18
  metadata: Record<string, any>;
19
- status: 'QUEUED' | 'PROCESSING' | 'COMPLETED' | 'FAILED' | 'PENDING';
19
+ status: "QUEUED" | "PROCESSING" | "COMPLETED" | "FAILED" | "PENDING";
20
20
  progress: number;
21
21
  remainingTime: string;
22
22
  results: Record<string, any>;
@@ -12,4 +12,4 @@ export async function up(knex: Knex): Promise<void> {
12
12
 
13
13
  export async function down(knex: Knex): Promise<void> {
14
14
  await knex.schema.dropTableIfExists("user");
15
- }
15
+ }
@@ -13,7 +13,10 @@ export async function up(knex: Knex): Promise<void> {
13
13
  .inTable("user")
14
14
  .onDelete("CASCADE");
15
15
 
16
- table.enu("status", ["COMPLETE", "IN PROGRESS", "FAILED"]).notNullable().defaultTo("IN PROGRESS");
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
+ }
@@ -32,4 +32,4 @@ export async function up(knex: Knex): Promise<void> {
32
32
 
33
33
  export async function down(knex: Knex): Promise<void> {
34
34
  await knex.schema.dropTableIfExists("folders");
35
- }
35
+ }
@@ -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
+ }
@@ -56,4 +56,4 @@ export async function down(knex: Knex): Promise<void> {
56
56
  await knex.schema.alterTable("user", (table) => {
57
57
  table.dropColumn("uuid");
58
58
  });
59
- }
59
+ }
@@ -1,9 +1,9 @@
1
1
  import type { Knex } from "knex";
2
2
 
3
3
  export async function up(knex: Knex): Promise<void> {
4
- await knex.schema.renameTable("user", "users");
4
+ await knex.schema.renameTable("user", "users");
5
5
  }
6
6
 
7
7
  export async function down(knex: Knex): Promise<void> {
8
- await knex.schema.renameTable("users", "user");
8
+ await knex.schema.renameTable("users", "user");
9
9
  }
@@ -10,4 +10,4 @@ export async function down(knex: Knex): Promise<void> {
10
10
  await knex.schema.alterTable("video", (table) => {
11
11
  table.dropColumn("name");
12
12
  });
13
- }
13
+ }
@@ -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(`CREATE TYPE "video_status" AS ENUM ('QUEUED', 'PROCESSING', 'COMPLETED', 'FAILED', 'PENDING');`);
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.specificType("status", "varchar(255)").notNullable().defaultTo("QUEUED").alter();
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
-
@@ -12,4 +12,4 @@ export async function down(knex: Knex): Promise<void> {
12
12
  ALTER TABLE "video"
13
13
  ALTER COLUMN "status" SET DEFAULT 'QUEUED';
14
14
  `);
15
- }
15
+ }
@@ -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('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();
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('auth');
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('video', (table) => {
6
- table.boolean('generateVideoOutput').notNullable().defaultTo(false);
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('video', (table) => {
13
- table.dropColumn('generateVideoOutput');
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('video', (table) => {
6
- table.string('videoOutputLocation').nullable();
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('video', (table) => {
13
- table.dropColumn('videoOutputLocation');
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('auth', (table) => {
6
- table.string('emailToken', 255).nullable();
7
- table.boolean('emailVerified').notNullable().defaultTo(false);
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('auth', (table) => {
14
- table.dropColumn('emailToken');
15
- table.dropColumn('emailVerified');
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
- await knex.schema.alterTable('users', (table) => {
6
- table.string('profilePhoto').nullable();
7
- table.string('company').nullable();
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
- await knex.schema.alterTable('users', (table) => {
14
- table.dropColumn('profilePhoto');
15
- table.dropColumn('company');
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('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);
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.foreign('userId').references('id').inTable('users').onDelete('CASCADE');
13
- table.index(['userId']);
14
- table.index(['token']);
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('user_push_notification_token');
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
- await knex.schema.alterTable('user_push_notification_token', (table) => {
6
- table.string('token_type').defaultTo('expo').notNullable();
7
- table.string('device_type');
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
- await knex.schema.alterTable('user_push_notification_token', (table) => {
14
- table.dropColumn('token_type');
15
- table.dropColumn('device_type');
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('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');
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.foreign('userId').references('id').inTable('users').onDelete('CASCADE');
13
+ table
14
+ .foreign("userId")
15
+ .references("id")
16
+ .inTable("users")
17
+ .onDelete("CASCADE");
15
18
 
16
19
  // Indexes
17
- table.index('userId');
18
- table.index('status');
20
+ table.index("userId");
21
+ table.index("status");
19
22
  });
20
23
 
21
24
  // Create message table
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();
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.foreign('chatId').references('id').inTable('chat').onDelete('CASCADE');
33
+ table
34
+ .foreign("chatId")
35
+ .references("id")
36
+ .inTable("chat")
37
+ .onDelete("CASCADE");
31
38
 
32
39
  // Indexes
33
- table.index('chatId');
34
- table.index('created_at');
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('message');
41
- await knex.schema.dropTableIfExists('chat');
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('chat', (table) => {
7
- table.uuid('uuid').defaultTo(knex.raw('gen_random_uuid()')).notNullable();
8
- table.index('uuid');
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('chat', (table) => {
15
- table.dropColumn('uuid');
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('study', (table) => {
6
- table.text('description').nullable();
7
- table.string('type', 50).notNullable().defaultTo('TMC');
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('study', (table) => {
14
- table.dropColumn('description');
15
- table.dropColumn('type');
13
+ await knex.schema.alterTable("study", (table) => {
14
+ table.dropColumn("description");
15
+ table.dropColumn("type");
16
16
  });
17
- }
17
+ }