clhq-postgres-module 1.1.0-alpha.172 → 1.1.0-alpha.174

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 (107) hide show
  1. package/dist/config/data-source.local.d.ts +3 -0
  2. package/dist/config/data-source.local.js +15 -0
  3. package/dist/migrations/1713000000001-InitialSchema.d.ts +6 -0
  4. package/dist/migrations/1713000000001-InitialSchema.js +196 -0
  5. package/dist/migrations/1713000000002-CoreBusinessTables.d.ts +6 -0
  6. package/dist/migrations/1713000000002-CoreBusinessTables.js +198 -0
  7. package/dist/migrations/1713000000003-RemainingCoreTables.d.ts +6 -0
  8. package/dist/migrations/1713000000003-RemainingCoreTables.js +160 -0
  9. package/dist/migrations/1713000000004-MediaConfigReferenceTables.d.ts +6 -0
  10. package/dist/migrations/1713000000004-MediaConfigReferenceTables.js +241 -0
  11. package/dist/migrations/1713000000005-VideoMediaTables.d.ts +6 -0
  12. package/dist/migrations/1713000000005-VideoMediaTables.js +98 -0
  13. package/dist/migrations/1713000000006-AddUserReferralColumns.d.ts +6 -0
  14. package/dist/migrations/1713000000006-AddUserReferralColumns.js +55 -0
  15. package/dist/migrations/1713000000007-AddUserProfileColumns.d.ts +6 -0
  16. package/dist/migrations/1713000000007-AddUserProfileColumns.js +73 -0
  17. package/dist/migrations/1713000000008-AddBillingInfoColumn.d.ts +6 -0
  18. package/dist/migrations/1713000000008-AddBillingInfoColumn.js +23 -0
  19. package/dist/migrations/1713000000009-AddWorkspaceStorageColumns.d.ts +6 -0
  20. package/dist/migrations/1713000000009-AddWorkspaceStorageColumns.js +49 -0
  21. package/dist/migrations/1713000000010-AddUniqueIdToAssets.d.ts +6 -0
  22. package/dist/migrations/1713000000010-AddUniqueIdToAssets.js +29 -0
  23. package/dist/migrations/{1713000000003-AddDescriptionToBrandKits.d.ts → 1713000000011-CreateReferralEventsTable.d.ts} +1 -1
  24. package/dist/migrations/1713000000011-CreateReferralEventsTable.js +72 -0
  25. package/dist/migrations/1713000000012-ExtendCreditTransactions.d.ts +6 -0
  26. package/dist/migrations/1713000000012-ExtendCreditTransactions.js +70 -0
  27. package/dist/migrations/1713000000013-AiVideoMakerTables.d.ts +6 -0
  28. package/dist/migrations/1713000000013-AiVideoMakerTables.js +122 -0
  29. package/dist/migrations/1713000000014-SeedReferralRewardRules.d.ts +6 -0
  30. package/dist/migrations/1713000000014-SeedReferralRewardRules.js +135 -0
  31. package/dist/migrations/{1713000000001-CreateSocialConnectionTables.d.ts → 1713000000015-CreateCreditAllocationsTable.d.ts} +1 -1
  32. package/dist/migrations/1713000000015-CreateCreditAllocationsTable.js +49 -0
  33. package/dist/migrations/1713000000016-CreateCreditConsumptionLogTable.d.ts +6 -0
  34. package/dist/migrations/1713000000016-CreateCreditConsumptionLogTable.js +55 -0
  35. package/dist/migrations/1713000000017-UpdateSubscriptionPlansCreditFields.d.ts +6 -0
  36. package/dist/migrations/1713000000017-UpdateSubscriptionPlansCreditFields.js +121 -0
  37. package/dist/migrations/1713000000018-CreateVideoProcessingTables.d.ts +6 -0
  38. package/dist/migrations/1713000000018-CreateVideoProcessingTables.js +111 -0
  39. package/dist/migrations/1713000000019-CreateAudioWaveformsTable.d.ts +6 -0
  40. package/dist/migrations/1713000000019-CreateAudioWaveformsTable.js +62 -0
  41. package/dist/migrations/1713000000020-EnablePgvectorExtension.d.ts +6 -0
  42. package/dist/migrations/1713000000020-EnablePgvectorExtension.js +30 -0
  43. package/dist/migrations/1713000000021-CreateMetadataServiceTables.d.ts +6 -0
  44. package/dist/migrations/1713000000021-CreateMetadataServiceTables.js +410 -0
  45. package/dist/migrations/1713000000022-OptimizeMetadataIndexes.d.ts +6 -0
  46. package/dist/migrations/1713000000022-OptimizeMetadataIndexes.js +334 -0
  47. package/dist/migrations/1713000000023-CreateSceneGeneratorTables.d.ts +6 -0
  48. package/dist/migrations/1713000000023-CreateSceneGeneratorTables.js +97 -0
  49. package/dist/migrations/1713000000024-CreateRemotionRendersTable.d.ts +6 -0
  50. package/dist/migrations/1713000000024-CreateRemotionRendersTable.js +71 -0
  51. package/dist/migrations/1713000000025-ExtendCreditAllocationSystem.d.ts +6 -0
  52. package/dist/migrations/1713000000025-ExtendCreditAllocationSystem.js +114 -0
  53. package/dist/migrations/{1713000000002-AddIsActiveToWorkspaceMembers.d.ts → 1713000000026-AddStatusToCreditTransactions.d.ts} +1 -1
  54. package/dist/migrations/1713000000026-AddStatusToCreditTransactions.js +63 -0
  55. package/dist/migrations/1713000000027-MigrateProjectDurationToSeconds.d.ts +6 -0
  56. package/dist/migrations/1713000000027-MigrateProjectDurationToSeconds.js +43 -0
  57. package/dist/migrations/1713000000028-CreateSceneTimelineTables.d.ts +6 -0
  58. package/dist/migrations/1713000000028-CreateSceneTimelineTables.js +159 -0
  59. package/dist/migrations/1713000000029-ConvertScenesToSeconds.d.ts +6 -0
  60. package/dist/migrations/1713000000029-ConvertScenesToSeconds.js +106 -0
  61. package/dist/migrations/1713000000030-ChangeDurationToDecimal.d.ts +6 -0
  62. package/dist/migrations/1713000000030-ChangeDurationToDecimal.js +34 -0
  63. package/dist/migrations/1713000000031-CreateVideoSubtitlesTable.d.ts +6 -0
  64. package/dist/migrations/1713000000031-CreateVideoSubtitlesTable.js +51 -0
  65. package/dist/migrations/1713000000032-AddWebpThumbnailColumns.d.ts +6 -0
  66. package/dist/migrations/1713000000032-AddWebpThumbnailColumns.js +58 -0
  67. package/dist/migrations/1713000000033-AddFormatToProjectScenes.d.ts +6 -0
  68. package/dist/migrations/1713000000033-AddFormatToProjectScenes.js +77 -0
  69. package/dist/migrations/1713000000034-FixProjectScenesUniqueConstraint.d.ts +6 -0
  70. package/dist/migrations/1713000000034-FixProjectScenesUniqueConstraint.js +39 -0
  71. package/dist/migrations/1713000000035-AddMissingVideoSubtitlesColumns.d.ts +6 -0
  72. package/dist/migrations/1713000000035-AddMissingVideoSubtitlesColumns.js +29 -0
  73. package/dist/migrations/1713000000036-AddRemotionRenderCreditColumns.d.ts +6 -0
  74. package/dist/migrations/1713000000036-AddRemotionRenderCreditColumns.js +50 -0
  75. package/dist/migrations/1713000000037-CreateProjectSharesTable.d.ts +6 -0
  76. package/dist/migrations/1713000000037-CreateProjectSharesTable.js +60 -0
  77. package/dist/migrations/1713000000038-EnableRlsOnAllTables.d.ts +6 -0
  78. package/dist/migrations/1713000000038-EnableRlsOnAllTables.js +97 -0
  79. package/dist/migrations/1713000000039-AiVideoMakerKlingFreeColumns.d.ts +6 -0
  80. package/dist/migrations/1713000000039-AiVideoMakerKlingFreeColumns.js +85 -0
  81. package/dist/migrations/1713000000040-CreateBrandKitsTable.d.ts +6 -0
  82. package/dist/migrations/1713000000040-CreateBrandKitsTable.js +44 -0
  83. package/dist/migrations/1713000000041-CreateBrandAssetsTable.d.ts +6 -0
  84. package/dist/migrations/1713000000041-CreateBrandAssetsTable.js +57 -0
  85. package/dist/migrations/1713000000042-AddActiveBrandKitToWorkspaces.d.ts +6 -0
  86. package/dist/migrations/1713000000042-AddActiveBrandKitToWorkspaces.js +43 -0
  87. package/dist/migrations/1713000000043-CreateAssetCategoriesTable.d.ts +6 -0
  88. package/dist/migrations/1713000000043-CreateAssetCategoriesTable.js +47 -0
  89. package/dist/migrations/1713000000044-AddEnforcementModeToWorkspaces.d.ts +6 -0
  90. package/dist/migrations/1713000000044-AddEnforcementModeToWorkspaces.js +21 -0
  91. package/dist/migrations/1713000000045-CreateProjectBrandOverridesTable.d.ts +6 -0
  92. package/dist/migrations/1713000000045-CreateProjectBrandOverridesTable.js +33 -0
  93. package/dist/migrations/1713000000046-AddPdfRenderSupport.d.ts +6 -0
  94. package/dist/migrations/1713000000046-AddPdfRenderSupport.js +14 -0
  95. package/dist/migrations/1713000000047-CreateSocialConnectionTables.d.ts +6 -0
  96. package/dist/migrations/{1713000000001-CreateSocialConnectionTables.js → 1713000000047-CreateSocialConnectionTables.js} +4 -4
  97. package/dist/migrations/1713000000048-AddIsActiveToWorkspaceMembers.d.ts +6 -0
  98. package/dist/migrations/{1713000000002-AddIsActiveToWorkspaceMembers.js → 1713000000048-AddIsActiveToWorkspaceMembers.js} +4 -4
  99. package/dist/migrations/1713000000049-AddDescriptionToBrandKits.d.ts +6 -0
  100. package/dist/migrations/{1713000000003-AddDescriptionToBrandKits.js → 1713000000049-AddDescriptionToBrandKits.js} +4 -4
  101. package/dist/migrations/1713000000050-CreateKlingGenerationTables.d.ts +6 -0
  102. package/dist/migrations/1713000000050-CreateKlingGenerationTables.js +76 -0
  103. package/dist/migrations/1713000000051-AddAiVideoSceneCanvasIdsAndThumbnail.d.ts +6 -0
  104. package/dist/migrations/1713000000051-AddAiVideoSceneCanvasIdsAndThumbnail.js +49 -0
  105. package/dist/migrations/1713000000052-AddAiVideoSourceMetadataAndMusicMeta.d.ts +6 -0
  106. package/dist/migrations/1713000000052-AddAiVideoSourceMetadataAndMusicMeta.js +67 -0
  107. package/package.json +8 -1
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FixProjectScenesUniqueConstraint1713000000034 = void 0;
4
+ class FixProjectScenesUniqueConstraint1713000000034 {
5
+ constructor() {
6
+ this.name = 'FixProjectScenesUniqueConstraint1713000000034';
7
+ }
8
+ async up(queryRunner) {
9
+ await queryRunner.query(`
10
+ DO $$
11
+ BEGIN
12
+ IF EXISTS (
13
+ SELECT 1 FROM pg_constraint
14
+ WHERE conname = 'project_scenes_project_id_timestamp_key'
15
+ ) THEN
16
+ ALTER TABLE project_scenes DROP CONSTRAINT project_scenes_project_id_timestamp_key;
17
+ END IF;
18
+
19
+ IF EXISTS (
20
+ SELECT 1 FROM pg_constraint
21
+ WHERE conname = 'project_scenes_project_id_timestamp_unique'
22
+ ) THEN
23
+ ALTER TABLE project_scenes DROP CONSTRAINT project_scenes_project_id_timestamp_unique;
24
+ END IF;
25
+ END $$;
26
+ `);
27
+ await queryRunner.query(`
28
+ CREATE UNIQUE INDEX IF NOT EXISTS project_scenes_project_id_timestamp_format_unique
29
+ ON project_scenes (project_id, timestamp, format);
30
+ `);
31
+ }
32
+ async down(queryRunner) {
33
+ await queryRunner.query(`DROP INDEX IF EXISTS project_scenes_project_id_timestamp_format_unique`);
34
+ await queryRunner.query(`
35
+ ALTER TABLE project_scenes ADD CONSTRAINT project_scenes_project_id_timestamp_key UNIQUE (project_id, timestamp);
36
+ `);
37
+ }
38
+ }
39
+ exports.FixProjectScenesUniqueConstraint1713000000034 = FixProjectScenesUniqueConstraint1713000000034;
@@ -0,0 +1,6 @@
1
+ import { MigrationInterface, QueryRunner } from 'typeorm';
2
+ export declare class AddMissingVideoSubtitlesColumns1713000000035 implements MigrationInterface {
3
+ name: string;
4
+ up(queryRunner: QueryRunner): Promise<void>;
5
+ down(queryRunner: QueryRunner): Promise<void>;
6
+ }
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AddMissingVideoSubtitlesColumns1713000000035 = void 0;
4
+ class AddMissingVideoSubtitlesColumns1713000000035 {
5
+ constructor() {
6
+ this.name = 'AddMissingVideoSubtitlesColumns1713000000035';
7
+ }
8
+ async up(queryRunner) {
9
+ await queryRunner.query(`
10
+ ALTER TABLE video_subtitles ADD COLUMN IF NOT EXISTS user_id VARCHAR(255);
11
+ `);
12
+ await queryRunner.query(`
13
+ ALTER TABLE video_subtitles ADD COLUMN IF NOT EXISTS file_name VARCHAR(255);
14
+ `);
15
+ await queryRunner.query(`
16
+ ALTER TABLE video_subtitles ADD COLUMN IF NOT EXISTS source VARCHAR(20);
17
+ `);
18
+ await queryRunner.query(`
19
+ CREATE INDEX IF NOT EXISTS idx_video_subtitles_user_id ON video_subtitles(user_id);
20
+ `);
21
+ }
22
+ async down(queryRunner) {
23
+ await queryRunner.query(`DROP INDEX IF EXISTS idx_video_subtitles_user_id`);
24
+ await queryRunner.query(`ALTER TABLE video_subtitles DROP COLUMN IF EXISTS source`);
25
+ await queryRunner.query(`ALTER TABLE video_subtitles DROP COLUMN IF EXISTS file_name`);
26
+ await queryRunner.query(`ALTER TABLE video_subtitles DROP COLUMN IF EXISTS user_id`);
27
+ }
28
+ }
29
+ exports.AddMissingVideoSubtitlesColumns1713000000035 = AddMissingVideoSubtitlesColumns1713000000035;
@@ -0,0 +1,6 @@
1
+ import { MigrationInterface, QueryRunner } from 'typeorm';
2
+ export declare class AddRemotionRenderCreditColumns1713000000036 implements MigrationInterface {
3
+ name: string;
4
+ up(queryRunner: QueryRunner): Promise<void>;
5
+ down(queryRunner: QueryRunner): Promise<void>;
6
+ }
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AddRemotionRenderCreditColumns1713000000036 = void 0;
4
+ class AddRemotionRenderCreditColumns1713000000036 {
5
+ constructor() {
6
+ this.name = 'AddRemotionRenderCreditColumns1713000000036';
7
+ }
8
+ async up(queryRunner) {
9
+ await queryRunner.query(`
10
+ DO $$
11
+ BEGIN
12
+ IF NOT EXISTS (
13
+ SELECT 1 FROM pg_enum
14
+ WHERE enumlabel = 'queued'
15
+ AND enumtypid = (SELECT oid FROM pg_type WHERE typname = 'render_status')
16
+ ) THEN
17
+ ALTER TYPE render_status ADD VALUE 'queued' BEFORE 'pending';
18
+ END IF;
19
+ END $$;
20
+ `);
21
+ await queryRunner.query(`
22
+ ALTER TABLE remotion_renders
23
+ ADD COLUMN IF NOT EXISTS credits_reserved DECIMAL(10, 2);
24
+ `);
25
+ await queryRunner.query(`
26
+ ALTER TABLE remotion_renders
27
+ ADD COLUMN IF NOT EXISTS credits_consumed DECIMAL(10, 2);
28
+ `);
29
+ await queryRunner.query(`
30
+ ALTER TABLE remotion_renders
31
+ ADD COLUMN IF NOT EXISTS reservation_id UUID;
32
+ `);
33
+ await queryRunner.query(`
34
+ ALTER TABLE remotion_renders
35
+ ADD COLUMN IF NOT EXISTS render_cost_metadata JSONB;
36
+ `);
37
+ await queryRunner.query(`
38
+ CREATE INDEX IF NOT EXISTS idx_remotion_renders_reservation_id
39
+ ON remotion_renders(reservation_id);
40
+ `);
41
+ }
42
+ async down(queryRunner) {
43
+ await queryRunner.query(`DROP INDEX IF EXISTS idx_remotion_renders_reservation_id`);
44
+ await queryRunner.query(`ALTER TABLE remotion_renders DROP COLUMN IF EXISTS render_cost_metadata`);
45
+ await queryRunner.query(`ALTER TABLE remotion_renders DROP COLUMN IF EXISTS reservation_id`);
46
+ await queryRunner.query(`ALTER TABLE remotion_renders DROP COLUMN IF EXISTS credits_consumed`);
47
+ await queryRunner.query(`ALTER TABLE remotion_renders DROP COLUMN IF EXISTS credits_reserved`);
48
+ }
49
+ }
50
+ exports.AddRemotionRenderCreditColumns1713000000036 = AddRemotionRenderCreditColumns1713000000036;
@@ -0,0 +1,6 @@
1
+ import { MigrationInterface, QueryRunner } from 'typeorm';
2
+ export declare class CreateProjectSharesTable1713000000037 implements MigrationInterface {
3
+ name: string;
4
+ up(queryRunner: QueryRunner): Promise<void>;
5
+ down(queryRunner: QueryRunner): Promise<void>;
6
+ }
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CreateProjectSharesTable1713000000037 = void 0;
4
+ class CreateProjectSharesTable1713000000037 {
5
+ constructor() {
6
+ this.name = 'CreateProjectSharesTable1713000000037';
7
+ }
8
+ async up(queryRunner) {
9
+ await queryRunner.query(`
10
+ DO $$ BEGIN
11
+ CREATE TYPE project_share_status AS ENUM ('active', 'revoked', 'expired');
12
+ EXCEPTION
13
+ WHEN duplicate_object THEN null;
14
+ END $$;
15
+ `);
16
+ await queryRunner.query(`
17
+ CREATE TABLE IF NOT EXISTS project_shares (
18
+ id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
19
+ project_id VARCHAR(255) NOT NULL,
20
+ owner_id UUID NOT NULL,
21
+ share_token VARCHAR(64) NOT NULL UNIQUE,
22
+ status project_share_status DEFAULT 'active',
23
+ allow_download BOOLEAN DEFAULT false,
24
+ expires_at TIMESTAMP WITH TIME ZONE,
25
+ revoked_at TIMESTAMP WITH TIME ZONE,
26
+ view_count INTEGER DEFAULT 0,
27
+ last_viewed_at TIMESTAMP WITH TIME ZONE,
28
+ created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
29
+ updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
30
+ CONSTRAINT fk_project_shares_project FOREIGN KEY (project_id) REFERENCES editor_projects(id) ON DELETE CASCADE,
31
+ CONSTRAINT fk_project_shares_owner FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE CASCADE
32
+ );
33
+ `);
34
+ await queryRunner.query(`
35
+ CREATE UNIQUE INDEX IF NOT EXISTS idx_project_shares_token ON project_shares(share_token);
36
+ `);
37
+ await queryRunner.query(`
38
+ CREATE INDEX IF NOT EXISTS idx_project_shares_project_id ON project_shares(project_id);
39
+ `);
40
+ await queryRunner.query(`
41
+ CREATE INDEX IF NOT EXISTS idx_project_shares_owner_id ON project_shares(owner_id);
42
+ `);
43
+ await queryRunner.query(`
44
+ CREATE INDEX IF NOT EXISTS idx_project_shares_status ON project_shares(status);
45
+ `);
46
+ await queryRunner.query(`
47
+ CREATE INDEX IF NOT EXISTS idx_project_shares_project_status ON project_shares(project_id, status);
48
+ `);
49
+ }
50
+ async down(queryRunner) {
51
+ await queryRunner.query(`DROP INDEX IF EXISTS idx_project_shares_project_status`);
52
+ await queryRunner.query(`DROP INDEX IF EXISTS idx_project_shares_status`);
53
+ await queryRunner.query(`DROP INDEX IF EXISTS idx_project_shares_owner_id`);
54
+ await queryRunner.query(`DROP INDEX IF EXISTS idx_project_shares_project_id`);
55
+ await queryRunner.query(`DROP INDEX IF EXISTS idx_project_shares_token`);
56
+ await queryRunner.query(`DROP TABLE IF EXISTS project_shares`);
57
+ await queryRunner.query(`DROP TYPE IF EXISTS project_share_status`);
58
+ }
59
+ }
60
+ exports.CreateProjectSharesTable1713000000037 = CreateProjectSharesTable1713000000037;
@@ -0,0 +1,6 @@
1
+ import { MigrationInterface, QueryRunner } from 'typeorm';
2
+ export declare class EnableRlsOnAllTables1713000000038 implements MigrationInterface {
3
+ name: string;
4
+ up(queryRunner: QueryRunner): Promise<void>;
5
+ down(queryRunner: QueryRunner): Promise<void>;
6
+ }
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EnableRlsOnAllTables1713000000038 = void 0;
4
+ class EnableRlsOnAllTables1713000000038 {
5
+ constructor() {
6
+ this.name = 'EnableRlsOnAllTables1713000000038';
7
+ }
8
+ async up(queryRunner) {
9
+ await queryRunner.query(`ALTER TABLE users ENABLE ROW LEVEL SECURITY`);
10
+ await queryRunner.query(`ALTER TABLE workspaces ENABLE ROW LEVEL SECURITY`);
11
+ await queryRunner.query(`ALTER TABLE workspace_members ENABLE ROW LEVEL SECURITY`);
12
+ await queryRunner.query(`ALTER TABLE editor_projects ENABLE ROW LEVEL SECURITY`);
13
+ await queryRunner.query(`ALTER TABLE project_scenes ENABLE ROW LEVEL SECURITY`);
14
+ await queryRunner.query(`ALTER TABLE project_scene_jobs ENABLE ROW LEVEL SECURITY`);
15
+ await queryRunner.query(`ALTER TABLE project_shares ENABLE ROW LEVEL SECURITY`);
16
+ await queryRunner.query(`ALTER TABLE project_metadata ENABLE ROW LEVEL SECURITY`);
17
+ await queryRunner.query(`ALTER TABLE scenes ENABLE ROW LEVEL SECURITY`);
18
+ await queryRunner.query(`ALTER TABLE items ENABLE ROW LEVEL SECURITY`);
19
+ await queryRunner.query(`ALTER TABLE user_subscriptions ENABLE ROW LEVEL SECURITY`);
20
+ await queryRunner.query(`ALTER TABLE subscription_plans ENABLE ROW LEVEL SECURITY`);
21
+ await queryRunner.query(`ALTER TABLE payment_transactions ENABLE ROW LEVEL SECURITY`);
22
+ await queryRunner.query(`ALTER TABLE stripe_webhook_events ENABLE ROW LEVEL SECURITY`);
23
+ await queryRunner.query(`ALTER TABLE subscription_usage ENABLE ROW LEVEL SECURITY`);
24
+ await queryRunner.query(`ALTER TABLE plans ENABLE ROW LEVEL SECURITY`);
25
+ await queryRunner.query(`ALTER TABLE credit_transactions ENABLE ROW LEVEL SECURITY`);
26
+ await queryRunner.query(`ALTER TABLE credit_allocations ENABLE ROW LEVEL SECURITY`);
27
+ await queryRunner.query(`ALTER TABLE credit_consumption_log ENABLE ROW LEVEL SECURITY`);
28
+ await queryRunner.query(`ALTER TABLE plan_credit_configurations ENABLE ROW LEVEL SECURITY`);
29
+ await queryRunner.query(`ALTER TABLE reward_rules ENABLE ROW LEVEL SECURITY`);
30
+ await queryRunner.query(`ALTER TABLE referral_events ENABLE ROW LEVEL SECURITY`);
31
+ await queryRunner.query(`ALTER TABLE assets ENABLE ROW LEVEL SECURITY`);
32
+ await queryRunner.query(`ALTER TABLE audio_waveforms ENABLE ROW LEVEL SECURITY`);
33
+ await queryRunner.query(`ALTER TABLE video_transcodes ENABLE ROW LEVEL SECURITY`);
34
+ await queryRunner.query(`ALTER TABLE video_filmstrips ENABLE ROW LEVEL SECURITY`);
35
+ await queryRunner.query(`ALTER TABLE video_renders ENABLE ROW LEVEL SECURITY`);
36
+ await queryRunner.query(`ALTER TABLE video_subtitles ENABLE ROW LEVEL SECURITY`);
37
+ await queryRunner.query(`ALTER TABLE ai_video_jobs ENABLE ROW LEVEL SECURITY`);
38
+ await queryRunner.query(`ALTER TABLE ai_video_scene_tasks ENABLE ROW LEVEL SECURITY`);
39
+ await queryRunner.query(`ALTER TABLE ai_usage ENABLE ROW LEVEL SECURITY`);
40
+ await queryRunner.query(`ALTER TABLE ai_embeddings ENABLE ROW LEVEL SECURITY`);
41
+ await queryRunner.query(`ALTER TABLE asset_metadata ENABLE ROW LEVEL SECURITY`);
42
+ await queryRunner.query(`ALTER TABLE user_context ENABLE ROW LEVEL SECURITY`);
43
+ await queryRunner.query(`ALTER TABLE metadata_activity_log ENABLE ROW LEVEL SECURITY`);
44
+ await queryRunner.query(`ALTER TABLE remotion_renders ENABLE ROW LEVEL SECURITY`);
45
+ await queryRunner.query(`ALTER TABLE user_profiles ENABLE ROW LEVEL SECURITY`);
46
+ await queryRunner.query(`ALTER TABLE user_onboarding_responses ENABLE ROW LEVEL SECURITY`);
47
+ await queryRunner.query(`ALTER TABLE auth_sessions ENABLE ROW LEVEL SECURITY`);
48
+ await queryRunner.query(`ALTER TABLE invites ENABLE ROW LEVEL SECURITY`);
49
+ await queryRunner.query(`ALTER TABLE comments ENABLE ROW LEVEL SECURITY`);
50
+ await queryRunner.query(`ALTER TABLE effects ENABLE ROW LEVEL SECURITY`);
51
+ }
52
+ async down(queryRunner) {
53
+ await queryRunner.query(`ALTER TABLE effects DISABLE ROW LEVEL SECURITY`);
54
+ await queryRunner.query(`ALTER TABLE comments DISABLE ROW LEVEL SECURITY`);
55
+ await queryRunner.query(`ALTER TABLE invites DISABLE ROW LEVEL SECURITY`);
56
+ await queryRunner.query(`ALTER TABLE auth_sessions DISABLE ROW LEVEL SECURITY`);
57
+ await queryRunner.query(`ALTER TABLE user_onboarding_responses DISABLE ROW LEVEL SECURITY`);
58
+ await queryRunner.query(`ALTER TABLE user_profiles DISABLE ROW LEVEL SECURITY`);
59
+ await queryRunner.query(`ALTER TABLE remotion_renders DISABLE ROW LEVEL SECURITY`);
60
+ await queryRunner.query(`ALTER TABLE metadata_activity_log DISABLE ROW LEVEL SECURITY`);
61
+ await queryRunner.query(`ALTER TABLE user_context DISABLE ROW LEVEL SECURITY`);
62
+ await queryRunner.query(`ALTER TABLE asset_metadata DISABLE ROW LEVEL SECURITY`);
63
+ await queryRunner.query(`ALTER TABLE ai_embeddings DISABLE ROW LEVEL SECURITY`);
64
+ await queryRunner.query(`ALTER TABLE ai_usage DISABLE ROW LEVEL SECURITY`);
65
+ await queryRunner.query(`ALTER TABLE ai_video_scene_tasks DISABLE ROW LEVEL SECURITY`);
66
+ await queryRunner.query(`ALTER TABLE ai_video_jobs DISABLE ROW LEVEL SECURITY`);
67
+ await queryRunner.query(`ALTER TABLE video_subtitles DISABLE ROW LEVEL SECURITY`);
68
+ await queryRunner.query(`ALTER TABLE video_renders DISABLE ROW LEVEL SECURITY`);
69
+ await queryRunner.query(`ALTER TABLE video_filmstrips DISABLE ROW LEVEL SECURITY`);
70
+ await queryRunner.query(`ALTER TABLE video_transcodes DISABLE ROW LEVEL SECURITY`);
71
+ await queryRunner.query(`ALTER TABLE audio_waveforms DISABLE ROW LEVEL SECURITY`);
72
+ await queryRunner.query(`ALTER TABLE assets DISABLE ROW LEVEL SECURITY`);
73
+ await queryRunner.query(`ALTER TABLE referral_events DISABLE ROW LEVEL SECURITY`);
74
+ await queryRunner.query(`ALTER TABLE reward_rules DISABLE ROW LEVEL SECURITY`);
75
+ await queryRunner.query(`ALTER TABLE plan_credit_configurations DISABLE ROW LEVEL SECURITY`);
76
+ await queryRunner.query(`ALTER TABLE credit_consumption_log DISABLE ROW LEVEL SECURITY`);
77
+ await queryRunner.query(`ALTER TABLE credit_allocations DISABLE ROW LEVEL SECURITY`);
78
+ await queryRunner.query(`ALTER TABLE credit_transactions DISABLE ROW LEVEL SECURITY`);
79
+ await queryRunner.query(`ALTER TABLE plans DISABLE ROW LEVEL SECURITY`);
80
+ await queryRunner.query(`ALTER TABLE subscription_usage DISABLE ROW LEVEL SECURITY`);
81
+ await queryRunner.query(`ALTER TABLE stripe_webhook_events DISABLE ROW LEVEL SECURITY`);
82
+ await queryRunner.query(`ALTER TABLE payment_transactions DISABLE ROW LEVEL SECURITY`);
83
+ await queryRunner.query(`ALTER TABLE subscription_plans DISABLE ROW LEVEL SECURITY`);
84
+ await queryRunner.query(`ALTER TABLE user_subscriptions DISABLE ROW LEVEL SECURITY`);
85
+ await queryRunner.query(`ALTER TABLE items DISABLE ROW LEVEL SECURITY`);
86
+ await queryRunner.query(`ALTER TABLE scenes DISABLE ROW LEVEL SECURITY`);
87
+ await queryRunner.query(`ALTER TABLE project_metadata DISABLE ROW LEVEL SECURITY`);
88
+ await queryRunner.query(`ALTER TABLE project_shares DISABLE ROW LEVEL SECURITY`);
89
+ await queryRunner.query(`ALTER TABLE project_scene_jobs DISABLE ROW LEVEL SECURITY`);
90
+ await queryRunner.query(`ALTER TABLE project_scenes DISABLE ROW LEVEL SECURITY`);
91
+ await queryRunner.query(`ALTER TABLE editor_projects DISABLE ROW LEVEL SECURITY`);
92
+ await queryRunner.query(`ALTER TABLE workspace_members DISABLE ROW LEVEL SECURITY`);
93
+ await queryRunner.query(`ALTER TABLE workspaces DISABLE ROW LEVEL SECURITY`);
94
+ await queryRunner.query(`ALTER TABLE users DISABLE ROW LEVEL SECURITY`);
95
+ }
96
+ }
97
+ exports.EnableRlsOnAllTables1713000000038 = EnableRlsOnAllTables1713000000038;
@@ -0,0 +1,6 @@
1
+ import { MigrationInterface, QueryRunner } from 'typeorm';
2
+ export declare class AiVideoMakerKlingFreeColumns1713000000039 implements MigrationInterface {
3
+ name: string;
4
+ up(queryRunner: QueryRunner): Promise<void>;
5
+ down(queryRunner: QueryRunner): Promise<void>;
6
+ }
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AiVideoMakerKlingFreeColumns1713000000039 = void 0;
4
+ class AiVideoMakerKlingFreeColumns1713000000039 {
5
+ constructor() {
6
+ this.name = 'AiVideoMakerKlingFreeColumns1713000000039';
7
+ }
8
+ async up(queryRunner) {
9
+ await queryRunner.query(`
10
+ ALTER TABLE ai_video_jobs ADD COLUMN IF NOT EXISTS workspace_id VARCHAR;
11
+ `);
12
+ await queryRunner.query(`
13
+ ALTER TABLE ai_video_jobs ADD COLUMN IF NOT EXISTS music_enabled BOOLEAN NOT NULL DEFAULT FALSE;
14
+ `);
15
+ await queryRunner.query(`
16
+ ALTER TABLE ai_video_jobs ADD COLUMN IF NOT EXISTS background_music_url TEXT;
17
+ `);
18
+ await queryRunner.query(`
19
+ ALTER TABLE ai_video_jobs ADD COLUMN IF NOT EXISTS output_url TEXT;
20
+ `);
21
+ await queryRunner.query(`
22
+ ALTER TABLE ai_video_jobs ADD COLUMN IF NOT EXISTS is_premium_user BOOLEAN NOT NULL DEFAULT FALSE;
23
+ `);
24
+ await queryRunner.query(`
25
+ ALTER TABLE ai_video_jobs ADD COLUMN IF NOT EXISTS kling_scenes_count INTEGER NOT NULL DEFAULT 0;
26
+ `);
27
+ await queryRunner.query(`
28
+ ALTER TABLE ai_video_scene_tasks ADD COLUMN IF NOT EXISTS pexels_video_id INTEGER;
29
+ `);
30
+ await queryRunner.query(`
31
+ ALTER TABLE ai_video_scene_tasks ADD COLUMN IF NOT EXISTS pixabay_video_id INTEGER;
32
+ `);
33
+ await queryRunner.query(`
34
+ ALTER TABLE ai_video_scene_tasks ADD COLUMN IF NOT EXISTS voice_audio_url TEXT;
35
+ `);
36
+ await queryRunner.query(`
37
+ ALTER TABLE ai_video_scene_tasks ADD COLUMN IF NOT EXISTS media_type VARCHAR DEFAULT 'video';
38
+ `);
39
+ await queryRunner.query(`
40
+ ALTER TABLE ai_video_scene_tasks ADD COLUMN IF NOT EXISTS shot_type VARCHAR;
41
+ `);
42
+ await queryRunner.query(`
43
+ ALTER TABLE ai_video_scene_tasks ADD COLUMN IF NOT EXISTS voiceover_duration_seconds DECIMAL(6,2);
44
+ `);
45
+ await queryRunner.query(`
46
+ ALTER TABLE ai_video_scene_tasks ADD COLUMN IF NOT EXISTS duration_seconds_adjusted INTEGER;
47
+ `);
48
+ await queryRunner.query(`COMMENT ON COLUMN ai_video_jobs.is_premium_user IS 'Whether Kling AI fallback was enabled for this job (premium user)'`);
49
+ await queryRunner.query(`COMMENT ON COLUMN ai_video_jobs.kling_scenes_count IS 'Number of scenes routed to Kling AI (only for premium users with low-confidence stock)'`);
50
+ await queryRunner.query(`COMMENT ON COLUMN ai_video_jobs.output_url IS 'S3 URL of rendered MP4 (only if auto-export was triggered)'`);
51
+ await queryRunner.query(`COMMENT ON COLUMN ai_video_jobs.background_music_url IS 'S3 URL of background music track'`);
52
+ await queryRunner.query(`COMMENT ON COLUMN ai_video_scene_tasks.media_type IS 'Whether stock result is video or image (image gets Ken Burns)'`);
53
+ await queryRunner.query(`COMMENT ON COLUMN ai_video_scene_tasks.shot_type IS 'Camera shot type from LLM script (maps to GSAP animation preset)'`);
54
+ await queryRunner.query(`COMMENT ON COLUMN ai_video_scene_tasks.voiceover_duration_seconds IS 'Actual voiceover audio duration (may differ from scene duration)'`);
55
+ await queryRunner.query(`COMMENT ON COLUMN ai_video_scene_tasks.voice_audio_url IS 'S3 URL of per-scene voiceover audio'`);
56
+ await queryRunner.query(`COMMENT ON COLUMN ai_video_scene_tasks.pexels_video_id IS 'Pexels video ID for URL refresh'`);
57
+ await queryRunner.query(`COMMENT ON COLUMN ai_video_scene_tasks.pixabay_video_id IS 'Pixabay video ID'`);
58
+ }
59
+ async down(queryRunner) {
60
+ await queryRunner.query(`COMMENT ON COLUMN ai_video_scene_tasks.pixabay_video_id IS NULL`);
61
+ await queryRunner.query(`COMMENT ON COLUMN ai_video_scene_tasks.pexels_video_id IS NULL`);
62
+ await queryRunner.query(`COMMENT ON COLUMN ai_video_scene_tasks.voice_audio_url IS NULL`);
63
+ await queryRunner.query(`COMMENT ON COLUMN ai_video_scene_tasks.voiceover_duration_seconds IS NULL`);
64
+ await queryRunner.query(`COMMENT ON COLUMN ai_video_scene_tasks.shot_type IS NULL`);
65
+ await queryRunner.query(`COMMENT ON COLUMN ai_video_scene_tasks.media_type IS NULL`);
66
+ await queryRunner.query(`COMMENT ON COLUMN ai_video_jobs.background_music_url IS NULL`);
67
+ await queryRunner.query(`COMMENT ON COLUMN ai_video_jobs.output_url IS NULL`);
68
+ await queryRunner.query(`COMMENT ON COLUMN ai_video_jobs.kling_scenes_count IS NULL`);
69
+ await queryRunner.query(`COMMENT ON COLUMN ai_video_jobs.is_premium_user IS NULL`);
70
+ await queryRunner.query(`ALTER TABLE ai_video_scene_tasks DROP COLUMN IF EXISTS duration_seconds_adjusted`);
71
+ await queryRunner.query(`ALTER TABLE ai_video_scene_tasks DROP COLUMN IF EXISTS voiceover_duration_seconds`);
72
+ await queryRunner.query(`ALTER TABLE ai_video_scene_tasks DROP COLUMN IF EXISTS shot_type`);
73
+ await queryRunner.query(`ALTER TABLE ai_video_scene_tasks DROP COLUMN IF EXISTS media_type`);
74
+ await queryRunner.query(`ALTER TABLE ai_video_scene_tasks DROP COLUMN IF EXISTS voice_audio_url`);
75
+ await queryRunner.query(`ALTER TABLE ai_video_scene_tasks DROP COLUMN IF EXISTS pixabay_video_id`);
76
+ await queryRunner.query(`ALTER TABLE ai_video_scene_tasks DROP COLUMN IF EXISTS pexels_video_id`);
77
+ await queryRunner.query(`ALTER TABLE ai_video_jobs DROP COLUMN IF EXISTS kling_scenes_count`);
78
+ await queryRunner.query(`ALTER TABLE ai_video_jobs DROP COLUMN IF EXISTS is_premium_user`);
79
+ await queryRunner.query(`ALTER TABLE ai_video_jobs DROP COLUMN IF EXISTS output_url`);
80
+ await queryRunner.query(`ALTER TABLE ai_video_jobs DROP COLUMN IF EXISTS background_music_url`);
81
+ await queryRunner.query(`ALTER TABLE ai_video_jobs DROP COLUMN IF EXISTS music_enabled`);
82
+ await queryRunner.query(`ALTER TABLE ai_video_jobs DROP COLUMN IF EXISTS workspace_id`);
83
+ }
84
+ }
85
+ exports.AiVideoMakerKlingFreeColumns1713000000039 = AiVideoMakerKlingFreeColumns1713000000039;
@@ -0,0 +1,6 @@
1
+ import { MigrationInterface, QueryRunner } from 'typeorm';
2
+ export declare class CreateBrandKitsTable1713000000040 implements MigrationInterface {
3
+ name: string;
4
+ up(queryRunner: QueryRunner): Promise<void>;
5
+ down(queryRunner: QueryRunner): Promise<void>;
6
+ }
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CreateBrandKitsTable1713000000040 = void 0;
4
+ class CreateBrandKitsTable1713000000040 {
5
+ constructor() {
6
+ this.name = 'CreateBrandKitsTable1713000000040';
7
+ }
8
+ async up(queryRunner) {
9
+ await queryRunner.query(`
10
+ CREATE TABLE IF NOT EXISTS brand_kits (
11
+ id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
12
+ workspace_id UUID NOT NULL,
13
+ name VARCHAR(255) NOT NULL,
14
+ primary_colors TEXT[] NOT NULL DEFAULT '{}',
15
+ secondary_colors TEXT[] NOT NULL DEFAULT '{}',
16
+ neutral_colors TEXT[] NOT NULL DEFAULT '{}',
17
+ heading_font_id UUID,
18
+ body_font_id UUID,
19
+ caption_font_id UUID,
20
+ is_active BOOLEAN NOT NULL DEFAULT true,
21
+ created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
22
+ updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
23
+ CONSTRAINT fk_brand_kits_workspace FOREIGN KEY (workspace_id) REFERENCES workspaces(id) ON DELETE CASCADE,
24
+ CONSTRAINT fk_brand_kits_heading_font FOREIGN KEY (heading_font_id) REFERENCES assets(id) ON DELETE SET NULL,
25
+ CONSTRAINT fk_brand_kits_body_font FOREIGN KEY (body_font_id) REFERENCES assets(id) ON DELETE SET NULL,
26
+ CONSTRAINT fk_brand_kits_caption_font FOREIGN KEY (caption_font_id) REFERENCES assets(id) ON DELETE SET NULL
27
+ );
28
+ `);
29
+ await queryRunner.query(`
30
+ CREATE INDEX IF NOT EXISTS idx_brand_kits_workspace_id ON brand_kits(workspace_id);
31
+ `);
32
+ await queryRunner.query(`
33
+ CREATE INDEX IF NOT EXISTS idx_brand_kits_workspace_is_active ON brand_kits(workspace_id, is_active);
34
+ `);
35
+ await queryRunner.query(`ALTER TABLE brand_kits ENABLE ROW LEVEL SECURITY`);
36
+ }
37
+ async down(queryRunner) {
38
+ await queryRunner.query(`ALTER TABLE brand_kits DISABLE ROW LEVEL SECURITY`);
39
+ await queryRunner.query(`DROP INDEX IF EXISTS idx_brand_kits_workspace_is_active`);
40
+ await queryRunner.query(`DROP INDEX IF EXISTS idx_brand_kits_workspace_id`);
41
+ await queryRunner.query(`DROP TABLE IF EXISTS brand_kits`);
42
+ }
43
+ }
44
+ exports.CreateBrandKitsTable1713000000040 = CreateBrandKitsTable1713000000040;
@@ -0,0 +1,6 @@
1
+ import { MigrationInterface, QueryRunner } from 'typeorm';
2
+ export declare class CreateBrandAssetsTable1713000000041 implements MigrationInterface {
3
+ name: string;
4
+ up(queryRunner: QueryRunner): Promise<void>;
5
+ down(queryRunner: QueryRunner): Promise<void>;
6
+ }
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CreateBrandAssetsTable1713000000041 = void 0;
4
+ class CreateBrandAssetsTable1713000000041 {
5
+ constructor() {
6
+ this.name = 'CreateBrandAssetsTable1713000000041';
7
+ }
8
+ async up(queryRunner) {
9
+ await queryRunner.query(`
10
+ DO $$ BEGIN
11
+ CREATE TYPE brand_asset_role AS ENUM (
12
+ 'logo_primary',
13
+ 'logo_secondary',
14
+ 'logo_favicon',
15
+ 'watermark',
16
+ 'footer_overlay',
17
+ 'intro_watermark',
18
+ 'heading_font',
19
+ 'body_font',
20
+ 'caption_font',
21
+ 'background',
22
+ 'guideline_pdf'
23
+ );
24
+ EXCEPTION
25
+ WHEN duplicate_object THEN null;
26
+ END $$;
27
+ `);
28
+ await queryRunner.query(`
29
+ CREATE TABLE IF NOT EXISTS brand_assets (
30
+ id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
31
+ brand_kit_id UUID NOT NULL,
32
+ asset_id UUID NOT NULL,
33
+ role brand_asset_role NOT NULL,
34
+ is_active BOOLEAN NOT NULL DEFAULT true,
35
+ created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
36
+ updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
37
+ CONSTRAINT fk_brand_assets_brand_kit FOREIGN KEY (brand_kit_id) REFERENCES brand_kits(id) ON DELETE CASCADE,
38
+ CONSTRAINT fk_brand_assets_asset FOREIGN KEY (asset_id) REFERENCES assets(id) ON DELETE CASCADE
39
+ );
40
+ `);
41
+ await queryRunner.query(`
42
+ CREATE INDEX IF NOT EXISTS idx_brand_assets_brand_kit_id ON brand_assets(brand_kit_id);
43
+ `);
44
+ await queryRunner.query(`
45
+ CREATE INDEX IF NOT EXISTS idx_brand_assets_brand_kit_role ON brand_assets(brand_kit_id, role);
46
+ `);
47
+ await queryRunner.query(`ALTER TABLE brand_assets ENABLE ROW LEVEL SECURITY`);
48
+ }
49
+ async down(queryRunner) {
50
+ await queryRunner.query(`ALTER TABLE brand_assets DISABLE ROW LEVEL SECURITY`);
51
+ await queryRunner.query(`DROP INDEX IF EXISTS idx_brand_assets_brand_kit_role`);
52
+ await queryRunner.query(`DROP INDEX IF EXISTS idx_brand_assets_brand_kit_id`);
53
+ await queryRunner.query(`DROP TABLE IF EXISTS brand_assets`);
54
+ await queryRunner.query(`DROP TYPE IF EXISTS brand_asset_role`);
55
+ }
56
+ }
57
+ exports.CreateBrandAssetsTable1713000000041 = CreateBrandAssetsTable1713000000041;
@@ -0,0 +1,6 @@
1
+ import { MigrationInterface, QueryRunner } from 'typeorm';
2
+ export declare class AddActiveBrandKitToWorkspaces1713000000042 implements MigrationInterface {
3
+ name: string;
4
+ up(queryRunner: QueryRunner): Promise<void>;
5
+ down(queryRunner: QueryRunner): Promise<void>;
6
+ }
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AddActiveBrandKitToWorkspaces1713000000042 = void 0;
4
+ class AddActiveBrandKitToWorkspaces1713000000042 {
5
+ constructor() {
6
+ this.name = 'AddActiveBrandKitToWorkspaces1713000000042';
7
+ }
8
+ async up(queryRunner) {
9
+ await queryRunner.query(`
10
+ ALTER TABLE workspaces
11
+ ADD COLUMN IF NOT EXISTS active_brand_kit_id UUID;
12
+ `);
13
+ await queryRunner.query(`
14
+ DO $$
15
+ BEGIN
16
+ IF NOT EXISTS (
17
+ SELECT 1 FROM information_schema.table_constraints
18
+ WHERE constraint_name = 'fk_workspaces_active_brand_kit'
19
+ AND table_name = 'workspaces'
20
+ ) THEN
21
+ ALTER TABLE workspaces
22
+ ADD CONSTRAINT fk_workspaces_active_brand_kit
23
+ FOREIGN KEY (active_brand_kit_id) REFERENCES brand_kits(id) ON DELETE SET NULL;
24
+ END IF;
25
+ END $$;
26
+ `);
27
+ await queryRunner.query(`
28
+ CREATE INDEX IF NOT EXISTS idx_workspaces_active_brand_kit_id ON workspaces(active_brand_kit_id);
29
+ `);
30
+ }
31
+ async down(queryRunner) {
32
+ await queryRunner.query(`DROP INDEX IF EXISTS idx_workspaces_active_brand_kit_id`);
33
+ await queryRunner.query(`
34
+ ALTER TABLE workspaces
35
+ DROP CONSTRAINT IF EXISTS fk_workspaces_active_brand_kit;
36
+ `);
37
+ await queryRunner.query(`
38
+ ALTER TABLE workspaces
39
+ DROP COLUMN IF EXISTS active_brand_kit_id;
40
+ `);
41
+ }
42
+ }
43
+ exports.AddActiveBrandKitToWorkspaces1713000000042 = AddActiveBrandKitToWorkspaces1713000000042;
@@ -0,0 +1,6 @@
1
+ import { MigrationInterface, QueryRunner } from 'typeorm';
2
+ export declare class CreateAssetCategoriesTable1713000000043 implements MigrationInterface {
3
+ name: string;
4
+ up(queryRunner: QueryRunner): Promise<void>;
5
+ down(queryRunner: QueryRunner): Promise<void>;
6
+ }
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CreateAssetCategoriesTable1713000000043 = void 0;
4
+ class CreateAssetCategoriesTable1713000000043 {
5
+ constructor() {
6
+ this.name = 'CreateAssetCategoriesTable1713000000043';
7
+ }
8
+ async up(queryRunner) {
9
+ await queryRunner.query(`
10
+ CREATE TABLE IF NOT EXISTS asset_categories (
11
+ id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
12
+ workspace_id UUID NOT NULL,
13
+ name VARCHAR(255) NOT NULL,
14
+ description TEXT,
15
+ created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
16
+ updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
17
+ deleted_at TIMESTAMP WITH TIME ZONE,
18
+ CONSTRAINT fk_asset_categories_workspace FOREIGN KEY (workspace_id) REFERENCES workspaces(id) ON DELETE CASCADE
19
+ );
20
+ `);
21
+ await queryRunner.query(`
22
+ CREATE INDEX IF NOT EXISTS idx_asset_categories_workspace_id ON asset_categories(workspace_id);
23
+ `);
24
+ await queryRunner.query(`
25
+ DO $$
26
+ BEGIN
27
+ IF NOT EXISTS (
28
+ SELECT 1 FROM information_schema.table_constraints
29
+ WHERE constraint_name = 'fk_assets_category'
30
+ AND table_name = 'assets'
31
+ ) THEN
32
+ ALTER TABLE assets
33
+ ADD CONSTRAINT fk_assets_category
34
+ FOREIGN KEY (category_id) REFERENCES asset_categories(id) ON DELETE SET NULL;
35
+ END IF;
36
+ END $$;
37
+ `);
38
+ await queryRunner.query(`ALTER TABLE asset_categories ENABLE ROW LEVEL SECURITY`);
39
+ }
40
+ async down(queryRunner) {
41
+ await queryRunner.query(`ALTER TABLE asset_categories DISABLE ROW LEVEL SECURITY`);
42
+ await queryRunner.query(`ALTER TABLE assets DROP CONSTRAINT IF EXISTS fk_assets_category`);
43
+ await queryRunner.query(`DROP INDEX IF EXISTS idx_asset_categories_workspace_id`);
44
+ await queryRunner.query(`DROP TABLE IF EXISTS asset_categories`);
45
+ }
46
+ }
47
+ exports.CreateAssetCategoriesTable1713000000043 = CreateAssetCategoriesTable1713000000043;
@@ -0,0 +1,6 @@
1
+ import { MigrationInterface, QueryRunner } from 'typeorm';
2
+ export declare class AddEnforcementModeToWorkspaces1713000000044 implements MigrationInterface {
3
+ name: string;
4
+ up(queryRunner: QueryRunner): Promise<void>;
5
+ down(queryRunner: QueryRunner): Promise<void>;
6
+ }