@taodigital/database 0.0.0-stage → 1.2.1
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/README.md +21 -2
- package/dist/index.d.ts +58 -0
- package/dist/index.js +209 -0
- package/package.json +29 -4
- package/prisma/migrations/0000_init/migration.sql +220 -0
- package/prisma/migrations/0001_tenant_isolation/migration.sql +43 -0
- package/prisma/migrations/0002_app_runtime_role/migration.sql +14 -0
- package/prisma/migrations/0003_skill_taxonomy/migration.sql +30 -0
- package/prisma/migrations/0004_extended_models/migration.sql +215 -0
- package/prisma/migrations/0005_enhanced_test_artifacts/migration.sql +24 -0
- package/prisma/migrations/0006_tenant_settings/migration.sql +28 -0
- package/prisma/migrations/0007_project_slug/migration.sql +11 -0
- package/prisma/migrations/0008_project_crawl_config/migration.sql +3 -0
- package/prisma/migrations/0009_tenant_slug/migration.sql +11 -0
- package/prisma/migrations/0010_user_password/migration.sql +3 -0
- package/prisma/migrations/0011_oauth_connections/migration.sql +78 -0
- package/prisma/migrations/0012_agent_webhooks/migration.sql +46 -0
- package/prisma/migrations/0013_project_artifacts/migration.sql +27 -0
- package/prisma/migrations/0014_knowledge_chunks/migration.sql +37 -0
- package/prisma/migrations/20260626022056_platform_job_migration/migration.sql +44 -0
- package/prisma/migrations/20260626053339_kag_schema_update/migration.sql +27 -0
- package/prisma/migrations/20260626053340_restore_bm25_index/migration.sql +13 -0
- package/prisma/migrations/20260626063704_token_optimisation/migration.sql +86 -0
- package/prisma/migrations/20260626080000_job_name/migration.sql +2 -0
- package/prisma/migrations/20260626090000_rls_missing_tables/migration.sql +39 -0
- package/prisma/migrations/20260626100000_token_budget/migration.sql +21 -0
- package/prisma/migrations/20260626110000_screen_groups/migration.sql +42 -0
- package/prisma/migrations/20260626120000_artifact_intelligence/migration.sql +5 -0
- package/prisma/migrations/20260626130000_notifications/migration.sql +34 -0
- package/prisma/migrations/20260627100000_element_viewport/migration.sql +2 -0
- package/prisma/migrations/20260627100000_screenshot_cloud_url/migration.sql +2 -0
- package/prisma/migrations/20260627110000_screenshot_index/migration.sql +2 -0
- package/prisma/migrations/20260627140000_artifact_storage_key/migration.sql +3 -0
- package/prisma/migrations/20260627150000_screen_lifecycle/migration.sql +5 -0
- package/prisma/migrations/20260627160000_native_app_support/migration.sql +41 -0
- package/prisma/migrations/20260627200000_rls_missing_tables/migration.sql +57 -0
- package/prisma/migrations/20260627210000_llmcalllog_tasktype/migration.sql +1 -0
- package/prisma/migrations/20260628100000_element_enrichment/migration.sql +7 -0
- package/prisma/migrations/20260628110000_element_hash/migration.sql +6 -0
- package/prisma/migrations/20260628120000_screen_diff/migration.sql +20 -0
- package/prisma/migrations/20260628130000_probe_observations/migration.sql +19 -0
- package/prisma/migrations/20260629100000_visual_baseline_masking/migration.sql +1 -0
- package/prisma/migrations/20260629110000_testcase_viewports/migration.sql +1 -0
- package/prisma/migrations/20260630100000_visual_baseline_element_snapshot/migration.sql +1 -0
- package/prisma/migrations/20260630110000_git_branched_baselines/migration.sql +11 -0
- package/prisma/migrations/20260630120000_testcase_viewport_constraint/migration.sql +1 -0
- package/prisma/migrations/20260630130000_test_case_runs/migration.sql +22 -0
- package/prisma/migrations/20260630140000_perf_env_comments/migration.sql +68 -0
- package/prisma/migrations/20260630150000_testcase_gen_at/migration.sql +2 -0
- package/prisma/migrations/20260630160000_rls_catchup_late_tables/migration.sql +41 -0
- package/prisma/migrations/20260701100000_skill_file_diff_approval/migration.sql +9 -0
- package/prisma/migrations/20260701200000_workspace_connector/migration.sql +20 -0
- package/prisma/migrations/20260701220000_screen_a11y_security/migration.sql +2 -0
- package/prisma/migrations/20260702100000_ci_threshold_root_cause/migration.sql +2 -0
- package/prisma/migrations/20260702120000_medium_priority_gaps/migration.sql +28 -0
- package/prisma/migrations/20260702140000_testcase_v2_technique/migration.sql +7 -0
- package/prisma/migrations/20260702150000_add_app_field/migration.sql +40 -0
- package/prisma/migrations/20260702160000_add_requirement_model/migration.sql +62 -0
- package/prisma/migrations/20260702180000_add_invitation_model/migration.sql +53 -0
- package/prisma/migrations/20260702190000_suite_hierarchy_artifact_trace/migration.sql +28 -0
- package/prisma/migrations/20260702200000_project_member_access/migration.sql +31 -0
- package/prisma/migrations/20260703000000_add_system_config/migration.sql +11 -0
- package/prisma/migrations/20260703000000_custom_roles/migration.sql +29 -0
- package/prisma/migrations/20260703100000_platform_admin/migration.sql +11 -0
- package/prisma/migrations/20260703110000_add_extension_models/migration.sql +106 -0
- package/prisma/migrations/20260703120000_project_restricted_column/migration.sql +1 -0
- package/prisma/migrations/20260703200000_system_config_category_index/migration.sql +1 -0
- package/prisma/migrations/20260703210000_workspace_layer/migration.sql +24 -0
- package/prisma/migrations/20260703230000_workspace_agent_tokens/migration.sql +2 -0
- package/prisma/migrations/20260704000000_requirement_rls_policy/migration.sql +35 -0
- package/prisma/migrations/20260704100000_fix_oauth_auditlog_cascade/migration.sql +9 -0
- package/prisma/migrations/20260704110000_skillfile_approval_status/migration.sql +2 -0
- package/prisma/migrations/20260704120000_scenario_suspect_workspace/migration.sql +35 -0
- package/prisma/migrations/20260704130000_testcase_traceto_suspect_indexes/migration.sql +5 -0
- package/prisma/migrations/20260704140000_workspace_rls/migration.sql +19 -0
- package/prisma/migrations/20260704150000_project_cascade_deletes/migration.sql +125 -0
- package/prisma/migrations/20260705100000_platform_job_worker_id/migration.sql +12 -0
- package/prisma/migrations/20260705110000_screen_discovery_method/migration.sql +7 -0
- package/prisma/migrations/20260705120000_webhook_delivery/migration.sql +32 -0
- package/prisma/migrations/20260705130000_tenant_feature_flags/migration.sql +23 -0
- package/prisma/migrations/20260705140000_auth_sessions/migration.sql +30 -0
- package/prisma/migrations/20260705150000_fix_rls_wrong_session_var/migration.sql +51 -0
- package/prisma/migrations/20260705160000_testcase_flaky_quarantine/migration.sql +14 -0
- package/prisma/migrations/20260705170000_testcaserun_browser/migration.sql +6 -0
- package/prisma/migrations/20260705180000_allow_custom_roles/migration.sql +22 -0
- package/prisma/migrations/20260706050000_screen_markdown_extraction/migration.sql +8 -0
- package/prisma/migrations/20260706090000_add_lighthouse_to_performance_snapshot/migration.sql +4 -0
- package/prisma/migrations/20260706100000_add_lighthouse_bp_and_job_index/migration.sql +5 -0
- package/prisma/migrations/20260706110000_add_visual_diff_ai_summary/migration.sql +2 -0
- package/prisma/migrations/20260707120000_script_bundles/migration.sql +25 -0
- package/prisma/migrations/20260707130000_requirement_source_section/migration.sql +4 -0
- package/prisma/migrations/20260707140000_structured_skill_metadata/migration.sql +8 -0
- package/prisma/migrations/20260707150000_crawler_platform_primitives/migration.sql +112 -0
- package/prisma/migrations/20260707160000_screen_group_versioning/migration.sql +9 -0
- package/prisma/migrations/20260707170000_add_mfa_fields/migration.sql +24 -0
- package/prisma/migrations/20260707180000_add_missing_tables/migration.sql +158 -0
- package/prisma/migrations/20260707190000_add_missing_columns/migration.sql +15 -0
- package/prisma/migrations/20260707200000_add_plan_sessions/migration.sql +1 -0
- package/prisma/migrations/20260708100000_missing_columns_comprehensive/migration.sql +15 -0
- package/prisma/migrations/20260708200000_testcase_dataset_column/migration.sql +16 -0
- package/prisma/migrations/20260709100000_add_filename_to_native_app_build/migration.sql +1 -0
- package/prisma/migrations/20260709200000_cloud_url_visual_artifacts/migration.sql +6 -0
- package/prisma/migrations/20260714200000_add_cached_scenarios_to_artifact/migration.sql +4 -0
- package/prisma/migrations/20260715200000_screen_markdown_content/migration.sql +2 -0
- package/prisma/migrations/20260716100000_github_repo_coverage_tables/migration.sql +114 -0
- package/prisma/migrations/20260716200000_github_pr_script_validation/migration.sql +48 -0
- package/prisma/migrations/20260716210000_s3_content_keys/migration.sql +20 -0
- package/prisma/migrations/20260717220000_ide_push_token/migration.sql +21 -0
- package/prisma/migrations/20260717230000_ide_push_script_ids/migration.sql +2 -0
- package/prisma/migrations/20260730040000_add_step_evidence_and_validation/migration.sql +93 -0
- package/prisma/migrations/20260803000000_add_tenantId_to_test_data_row/migration.sql +40 -0
- package/prisma/migrations/20260804000000_add_project_restricted/migration.sql +6 -0
- package/prisma/migrations/20260804000000_add_user_avatar_url/migration.sql +4 -0
- package/prisma/migrations/20260805000000_add_auditlog_ipaddress/migration.sql +2 -0
- package/prisma/migrations/20260807000000_add_test_data_classification/migration.sql +18 -0
- package/prisma/migrations/20260807000001_add_test_case_notes/migration.sql +5 -0
- package/prisma/migrations/20260807000002_add_visual_baseline_browser_structured_steps/migration.sql +11 -0
- package/prisma/migrations/20260807100000_add_tenant_plan_config/migration.sql +14 -0
- package/prisma/migrations/20260808000000_agent_token_missing_columns/migration.sql +22 -0
- package/prisma/migrations/20260808000001_visual_diff_image_and_threshold/migration.sql +8 -0
- package/prisma/migrations/20260808000002_ssoconfig_email_domains/migration.sql +7 -0
- package/prisma/migrations/20260808000003_project_status_description_updatedat/migration.sql +7 -0
- package/prisma/migrations/20260814000000_workspace_require_mfa/migration.sql +2 -0
- package/prisma/migrations/20260814000001_add_screenshot_dpr/migration.sql +2 -0
- package/prisma/migrations/20260818000000_add_content_hash_to_test_case/migration.sql +6 -0
- package/prisma/migrations/20260818000001_add_grounding_hash_to_test_case/migration.sql +3 -0
- package/prisma/migrations/20260819000000_coverage_mapping_cross_encoder_fields/migration.sql +3 -0
- package/prisma/migrations/20260820000000_add_locators_json_to_test_case/migration.sql +6 -0
- package/prisma/migrations/20260820000001_add_test_case_version/migration.sql +27 -0
- package/prisma/migrations/20260826000000_add_capture_step_screenshots/migration.sql +1 -0
- package/prisma/migrations/20260903000000_add_platform_job_dlq/migration.sql +10 -0
- package/prisma/migrations/20260903000002_add_versioning_tables/migration.sql +38 -0
- package/prisma/migrations/20260903000003_add_learning_models/migration.sql +71 -0
- package/prisma/migrations/20260903000004_add_workspace_agent_prompts/migration.sql +33 -0
- package/prisma/migrations/20260903000005_add_config_history/migration.sql +70 -0
- package/prisma/migrations/20260903000006_add_skill_file_config/migration.sql +24 -0
- package/prisma/migrations/20260904000000_add_agent_prompt_platform_table/migration.sql +23 -0
- package/prisma/migrations/20260904180424_rbac_role_configs_admin_roles/migration.sql +606 -0
- package/prisma/migrations/20260907000000_fix_testcase_timestamps/migration.sql +13 -0
- package/prisma/migrations/20260907000001_add_artifact_imported_suite_id/migration.sql +1 -0
- package/prisma/migrations/20260907000002_add_user_login_tracking/migration.sql +9 -0
- package/prisma/migrations/20260907000003_add_artifact_import_tracking/migration.sql +9 -0
- package/prisma/migrations/20260907000004_add_artifact_version_chain/migration.sql +18 -0
- package/prisma/migrations/20260908000000_add_project_vsa_enabled/migration.sql +2 -0
- package/prisma/migrations/20260908000001_rbac_migration_catchup/migration.sql +314 -0
- package/prisma/migrations/20260908000002_fix_role_configs_empty_permissions/migration.sql +22 -0
- package/prisma/migrations/20260908000003_sync_builtin_role_permissions/migration.sql +38 -0
- package/prisma/migrations/20260909000000_add_filepath_to_testscript/migration.sql +5 -0
- package/prisma/migrations/20260909000001_add_alignment_result_table/migration.sql +31 -0
- package/prisma/migrations/20260910000000_add_admin_mfa/migration.sql +35 -0
- package/prisma/migrations/20260910000000_add_dom_snapshot_cloud_url/migration.sql +2 -0
- package/prisma/migrations/20260910000001_add_requires_auth_to_screen/migration.sql +1 -0
- package/prisma/migrations/20260910000002_add_screen_requires_auth/migration.sql +2 -0
- package/prisma/migrations/20260910000003_add_admin_auth_sessions/migration.sql +17 -0
- package/prisma/migrations/20260916000001_add_admin_last_login/migration.sql +1 -0
- package/prisma/migrations/20260916000002_add_admin_failed_login/migration.sql +2 -0
- package/prisma/migrations/20260916000003_seed_system_tenant/migration.sql +6 -0
- package/prisma/migrations/20260918000000_fix_permissions_comprehensive/migration.sql +63 -0
- package/prisma/migrations/20260924000000_add_screen_role_access/migration.sql +2 -0
- package/prisma/migrations/20260928000000_add_navigation_graph/migration.sql +41 -0
- package/prisma/migrations/20260929000000_artifact_content_hash_suite_unique/migration.sql +25 -0
- package/prisma/migrations/20260929000000_navigation_graph_unique_constraint/migration.sql +5 -0
- package/prisma/migrations/20260929000001_add_membership_status/migration.sql +7 -0
- package/prisma/migrations/20260929000002_add_sso_config_scim_token_hash/migration.sql +8 -0
- package/prisma/migrations/20261005000001_jobs_workers_hardening/migration.sql +63 -0
- package/prisma/migrations/20261009000001_add_suite_category/migration.sql +2 -0
- package/prisma/migrations/20261009000002_add_testcase_approved_fields/migration.sql +3 -0
- package/prisma/migrations/20261012_auto_version_history/migration.sql +111 -0
- package/prisma/migrations/20261015000001_traceability_alignment_gaps/migration.sql +11 -0
- package/prisma/migrations/20261028000001_context_intelligence_p1_p7/migration.sql +76 -0
- package/prisma/migrations/migration_lock.toml +3 -0
- package/prisma/schema.prisma +2901 -0
- package/prisma/seed.ts +1262 -0
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
-- Migration: 0004_extended_models
|
|
2
|
+
-- Creates all tables added to schema.prisma after the initial migration:
|
|
3
|
+
-- CrawlJob, ElementFingerprint, UserSession, VisualBaseline, VisualDiff,
|
|
4
|
+
-- HumanReviewItem, TestRun, TestResult
|
|
5
|
+
-- Also adds the @@unique([testCaseId, language]) constraint on TestScript.
|
|
6
|
+
|
|
7
|
+
-- CreateTable
|
|
8
|
+
CREATE TABLE "CrawlJob" (
|
|
9
|
+
"id" TEXT NOT NULL,
|
|
10
|
+
"tenantId" TEXT NOT NULL,
|
|
11
|
+
"projectId" TEXT NOT NULL,
|
|
12
|
+
"status" TEXT NOT NULL DEFAULT 'QUEUED',
|
|
13
|
+
"config" JSONB NOT NULL,
|
|
14
|
+
"result" JSONB,
|
|
15
|
+
"error" TEXT,
|
|
16
|
+
"progress" INTEGER NOT NULL DEFAULT 0,
|
|
17
|
+
"queuedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
18
|
+
"startedAt" TIMESTAMP(3),
|
|
19
|
+
"finishedAt" TIMESTAMP(3),
|
|
20
|
+
|
|
21
|
+
CONSTRAINT "CrawlJob_pkey" PRIMARY KEY ("id")
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
-- CreateTable
|
|
25
|
+
CREATE TABLE "ElementFingerprint" (
|
|
26
|
+
"id" TEXT NOT NULL,
|
|
27
|
+
"tenantId" TEXT NOT NULL,
|
|
28
|
+
"projectId" TEXT NOT NULL,
|
|
29
|
+
"elementId" TEXT NOT NULL,
|
|
30
|
+
"selectors" JSONB NOT NULL,
|
|
31
|
+
"lastHealedAt" TIMESTAMP(3),
|
|
32
|
+
"healCount" INTEGER NOT NULL DEFAULT 0,
|
|
33
|
+
|
|
34
|
+
CONSTRAINT "ElementFingerprint_pkey" PRIMARY KEY ("id")
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
-- CreateTable
|
|
38
|
+
CREATE TABLE "UserSession" (
|
|
39
|
+
"id" TEXT NOT NULL,
|
|
40
|
+
"tenantId" TEXT NOT NULL,
|
|
41
|
+
"projectId" TEXT NOT NULL,
|
|
42
|
+
"source" TEXT NOT NULL,
|
|
43
|
+
"startUrl" TEXT NOT NULL,
|
|
44
|
+
"events" JSONB NOT NULL,
|
|
45
|
+
"duration" INTEGER,
|
|
46
|
+
"status" TEXT NOT NULL DEFAULT 'PENDING',
|
|
47
|
+
"convertedSuiteId" TEXT,
|
|
48
|
+
"recordedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
49
|
+
|
|
50
|
+
CONSTRAINT "UserSession_pkey" PRIMARY KEY ("id")
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
-- CreateTable
|
|
54
|
+
CREATE TABLE "VisualBaseline" (
|
|
55
|
+
"id" TEXT NOT NULL,
|
|
56
|
+
"tenantId" TEXT NOT NULL,
|
|
57
|
+
"projectId" TEXT NOT NULL,
|
|
58
|
+
"screenId" TEXT NOT NULL,
|
|
59
|
+
"viewport" TEXT NOT NULL DEFAULT 'DESKTOP',
|
|
60
|
+
"storagePath" TEXT NOT NULL,
|
|
61
|
+
"approvedBy" TEXT,
|
|
62
|
+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
63
|
+
|
|
64
|
+
CONSTRAINT "VisualBaseline_pkey" PRIMARY KEY ("id")
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
-- CreateTable
|
|
68
|
+
CREATE TABLE "VisualDiff" (
|
|
69
|
+
"id" TEXT NOT NULL,
|
|
70
|
+
"tenantId" TEXT NOT NULL,
|
|
71
|
+
"baselineId" TEXT NOT NULL,
|
|
72
|
+
"newScreenshotPath" TEXT NOT NULL,
|
|
73
|
+
"diffScore" DOUBLE PRECISION NOT NULL,
|
|
74
|
+
"changeType" TEXT NOT NULL,
|
|
75
|
+
"changes" JSONB,
|
|
76
|
+
"recommendation" TEXT,
|
|
77
|
+
"bugReportDraft" JSONB,
|
|
78
|
+
"status" TEXT NOT NULL DEFAULT 'PENDING',
|
|
79
|
+
"reviewedBy" TEXT,
|
|
80
|
+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
81
|
+
|
|
82
|
+
CONSTRAINT "VisualDiff_pkey" PRIMARY KEY ("id")
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
-- CreateTable
|
|
86
|
+
CREATE TABLE "HumanReviewItem" (
|
|
87
|
+
"id" TEXT NOT NULL,
|
|
88
|
+
"tenantId" TEXT NOT NULL,
|
|
89
|
+
"projectId" TEXT NOT NULL,
|
|
90
|
+
"testCaseId" TEXT NOT NULL,
|
|
91
|
+
"reason" TEXT NOT NULL,
|
|
92
|
+
"confidence" DOUBLE PRECISION NOT NULL,
|
|
93
|
+
"context" JSONB,
|
|
94
|
+
"status" TEXT NOT NULL DEFAULT 'PENDING',
|
|
95
|
+
"assignedTo" TEXT,
|
|
96
|
+
"resolution" TEXT,
|
|
97
|
+
"reviewedAt" TIMESTAMP(3),
|
|
98
|
+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
99
|
+
|
|
100
|
+
CONSTRAINT "HumanReviewItem_pkey" PRIMARY KEY ("id")
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
-- CreateTable
|
|
104
|
+
CREATE TABLE "TestRun" (
|
|
105
|
+
"id" TEXT NOT NULL,
|
|
106
|
+
"tenantId" TEXT NOT NULL,
|
|
107
|
+
"projectId" TEXT NOT NULL,
|
|
108
|
+
"suiteId" TEXT,
|
|
109
|
+
"trigger" TEXT NOT NULL DEFAULT 'MANUAL',
|
|
110
|
+
"status" TEXT NOT NULL DEFAULT 'RUNNING',
|
|
111
|
+
"config" JSONB,
|
|
112
|
+
"summary" JSONB,
|
|
113
|
+
"startedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
114
|
+
"finishedAt" TIMESTAMP(3),
|
|
115
|
+
|
|
116
|
+
CONSTRAINT "TestRun_pkey" PRIMARY KEY ("id")
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
-- CreateTable
|
|
120
|
+
CREATE TABLE "TestResult" (
|
|
121
|
+
"id" TEXT NOT NULL,
|
|
122
|
+
"tenantId" TEXT NOT NULL,
|
|
123
|
+
"runId" TEXT NOT NULL,
|
|
124
|
+
"testCaseId" TEXT NOT NULL,
|
|
125
|
+
"status" TEXT NOT NULL,
|
|
126
|
+
"duration" INTEGER,
|
|
127
|
+
"error" TEXT,
|
|
128
|
+
"screenshotPath" TEXT,
|
|
129
|
+
"logs" JSONB,
|
|
130
|
+
"healedAt" TIMESTAMP(3),
|
|
131
|
+
|
|
132
|
+
CONSTRAINT "TestResult_pkey" PRIMARY KEY ("id")
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
-- CreateIndex
|
|
136
|
+
CREATE INDEX "CrawlJob_tenantId_projectId_idx" ON "CrawlJob"("tenantId", "projectId");
|
|
137
|
+
|
|
138
|
+
-- CreateIndex
|
|
139
|
+
CREATE INDEX "CrawlJob_status_idx" ON "CrawlJob"("status");
|
|
140
|
+
|
|
141
|
+
-- CreateIndex
|
|
142
|
+
CREATE UNIQUE INDEX "ElementFingerprint_elementId_key" ON "ElementFingerprint"("elementId");
|
|
143
|
+
|
|
144
|
+
-- CreateIndex
|
|
145
|
+
CREATE INDEX "ElementFingerprint_tenantId_projectId_idx" ON "ElementFingerprint"("tenantId", "projectId");
|
|
146
|
+
|
|
147
|
+
-- CreateIndex
|
|
148
|
+
CREATE INDEX "UserSession_tenantId_projectId_idx" ON "UserSession"("tenantId", "projectId");
|
|
149
|
+
|
|
150
|
+
-- CreateIndex
|
|
151
|
+
CREATE INDEX "UserSession_status_idx" ON "UserSession"("status");
|
|
152
|
+
|
|
153
|
+
-- CreateIndex
|
|
154
|
+
CREATE INDEX "VisualBaseline_tenantId_projectId_idx" ON "VisualBaseline"("tenantId", "projectId");
|
|
155
|
+
|
|
156
|
+
-- CreateIndex
|
|
157
|
+
CREATE UNIQUE INDEX "VisualBaseline_screenId_viewport_key" ON "VisualBaseline"("screenId", "viewport");
|
|
158
|
+
|
|
159
|
+
-- CreateIndex
|
|
160
|
+
CREATE INDEX "VisualDiff_tenantId_baselineId_idx" ON "VisualDiff"("tenantId", "baselineId");
|
|
161
|
+
|
|
162
|
+
-- CreateIndex
|
|
163
|
+
CREATE INDEX "VisualDiff_status_idx" ON "VisualDiff"("status");
|
|
164
|
+
|
|
165
|
+
-- CreateIndex
|
|
166
|
+
CREATE INDEX "HumanReviewItem_tenantId_projectId_idx" ON "HumanReviewItem"("tenantId", "projectId");
|
|
167
|
+
|
|
168
|
+
-- CreateIndex
|
|
169
|
+
CREATE INDEX "HumanReviewItem_status_idx" ON "HumanReviewItem"("status");
|
|
170
|
+
|
|
171
|
+
-- CreateIndex
|
|
172
|
+
CREATE INDEX "TestRun_tenantId_projectId_idx" ON "TestRun"("tenantId", "projectId");
|
|
173
|
+
|
|
174
|
+
-- CreateIndex
|
|
175
|
+
CREATE INDEX "TestRun_status_idx" ON "TestRun"("status");
|
|
176
|
+
|
|
177
|
+
-- CreateIndex
|
|
178
|
+
CREATE INDEX "TestResult_tenantId_runId_idx" ON "TestResult"("tenantId", "runId");
|
|
179
|
+
|
|
180
|
+
-- CreateIndex
|
|
181
|
+
CREATE INDEX "TestResult_testCaseId_idx" ON "TestResult"("testCaseId");
|
|
182
|
+
|
|
183
|
+
-- CreateIndex (safe — no existing data to conflict)
|
|
184
|
+
CREATE UNIQUE INDEX IF NOT EXISTS "TestScript_testCaseId_language_key" ON "TestScript"("testCaseId", "language");
|
|
185
|
+
|
|
186
|
+
-- AddForeignKey
|
|
187
|
+
ALTER TABLE "CrawlJob" ADD CONSTRAINT "CrawlJob_projectId_fkey" FOREIGN KEY ("projectId") REFERENCES "Project"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
188
|
+
|
|
189
|
+
-- AddForeignKey
|
|
190
|
+
ALTER TABLE "ElementFingerprint" ADD CONSTRAINT "ElementFingerprint_elementId_fkey" FOREIGN KEY ("elementId") REFERENCES "Element"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
191
|
+
|
|
192
|
+
-- AddForeignKey
|
|
193
|
+
ALTER TABLE "UserSession" ADD CONSTRAINT "UserSession_projectId_fkey" FOREIGN KEY ("projectId") REFERENCES "Project"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
194
|
+
|
|
195
|
+
-- AddForeignKey
|
|
196
|
+
ALTER TABLE "VisualBaseline" ADD CONSTRAINT "VisualBaseline_screenId_fkey" FOREIGN KEY ("screenId") REFERENCES "Screen"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
197
|
+
|
|
198
|
+
-- AddForeignKey
|
|
199
|
+
ALTER TABLE "VisualDiff" ADD CONSTRAINT "VisualDiff_baselineId_fkey" FOREIGN KEY ("baselineId") REFERENCES "VisualBaseline"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
200
|
+
|
|
201
|
+
-- AddForeignKey
|
|
202
|
+
ALTER TABLE "HumanReviewItem" ADD CONSTRAINT "HumanReviewItem_testCaseId_fkey" FOREIGN KEY ("testCaseId") REFERENCES "TestCase"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
203
|
+
|
|
204
|
+
-- AddForeignKey
|
|
205
|
+
ALTER TABLE "TestRun" ADD CONSTRAINT "TestRun_projectId_fkey" FOREIGN KEY ("projectId") REFERENCES "Project"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
206
|
+
|
|
207
|
+
-- AddForeignKey
|
|
208
|
+
ALTER TABLE "TestResult" ADD CONSTRAINT "TestResult_runId_fkey" FOREIGN KEY ("runId") REFERENCES "TestRun"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
209
|
+
|
|
210
|
+
-- AddForeignKey
|
|
211
|
+
ALTER TABLE "TestResult" ADD CONSTRAINT "TestResult_testCaseId_fkey" FOREIGN KEY ("testCaseId") REFERENCES "TestCase"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
212
|
+
|
|
213
|
+
-- RLS: new tables inherit tenant isolation from the existing app role policies.
|
|
214
|
+
-- Existing policy on all tables: SELECT/INSERT/UPDATE/DELETE WHERE tenantId = current_setting('app.current_tenant_id').
|
|
215
|
+
-- No additional policy needed — the withTenant() wrapper in application code sets this.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
-- Migration 0005: Enhanced test artifacts
|
|
2
|
+
-- Adds market-standard fields to TestCase for Gherkin, priority, preconditions,
|
|
3
|
+
-- expectedResult, source, screenId (grounded element link), ref (human ID), tags, references.
|
|
4
|
+
|
|
5
|
+
ALTER TABLE "TestCase"
|
|
6
|
+
ADD COLUMN IF NOT EXISTS "priority" TEXT NOT NULL DEFAULT 'HIGH',
|
|
7
|
+
ADD COLUMN IF NOT EXISTS "preconditions" TEXT,
|
|
8
|
+
ADD COLUMN IF NOT EXISTS "expectedResult" TEXT,
|
|
9
|
+
ADD COLUMN IF NOT EXISTS "gherkin" TEXT,
|
|
10
|
+
ADD COLUMN IF NOT EXISTS "source" TEXT NOT NULL DEFAULT 'AI_GENERATED',
|
|
11
|
+
ADD COLUMN IF NOT EXISTS "screenId" TEXT,
|
|
12
|
+
ADD COLUMN IF NOT EXISTS "ref" TEXT,
|
|
13
|
+
ADD COLUMN IF NOT EXISTS "tags" JSONB NOT NULL DEFAULT '[]',
|
|
14
|
+
ADD COLUMN IF NOT EXISTS "caseRefs" JSONB NOT NULL DEFAULT '[]';
|
|
15
|
+
|
|
16
|
+
-- Optional FK: screenId -> Screen (nullable — some cases span multiple screens)
|
|
17
|
+
ALTER TABLE "TestCase"
|
|
18
|
+
ADD CONSTRAINT "TestCase_screenId_fkey"
|
|
19
|
+
FOREIGN KEY ("screenId") REFERENCES "Screen"("id")
|
|
20
|
+
ON DELETE SET NULL ON UPDATE CASCADE;
|
|
21
|
+
|
|
22
|
+
CREATE INDEX IF NOT EXISTS "TestCase_screenId_idx" ON "TestCase"("screenId");
|
|
23
|
+
CREATE INDEX IF NOT EXISTS "TestCase_priority_idx" ON "TestCase"("priority");
|
|
24
|
+
CREATE INDEX IF NOT EXISTS "TestCase_source_idx" ON "TestCase"("source");
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
-- 0006: workspace-level tenant settings (LLM provider, etc.)
|
|
2
|
+
CREATE TABLE IF NOT EXISTS "TenantSetting" (
|
|
3
|
+
"id" TEXT NOT NULL,
|
|
4
|
+
"tenantId" TEXT NOT NULL,
|
|
5
|
+
-- "LLM" | "NOTIFICATIONS" | "BRANDING"
|
|
6
|
+
"category" TEXT NOT NULL,
|
|
7
|
+
-- Encrypted JSON blob (sensitive fields use _enc suffix, same as Connector)
|
|
8
|
+
"config" JSONB NOT NULL DEFAULT '{}',
|
|
9
|
+
"updatedAt" TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
10
|
+
CONSTRAINT "TenantSetting_pkey" PRIMARY KEY ("id")
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
CREATE UNIQUE INDEX IF NOT EXISTS "TenantSetting_tenantId_category_key"
|
|
14
|
+
ON "TenantSetting"("tenantId", "category");
|
|
15
|
+
CREATE INDEX IF NOT EXISTS "TenantSetting_tenantId_idx"
|
|
16
|
+
ON "TenantSetting"("tenantId");
|
|
17
|
+
|
|
18
|
+
-- RLS: same isolation pattern as all other tables
|
|
19
|
+
ALTER TABLE "TenantSetting" ENABLE ROW LEVEL SECURITY;
|
|
20
|
+
DO $$ BEGIN
|
|
21
|
+
IF NOT EXISTS (
|
|
22
|
+
SELECT 1 FROM pg_policies WHERE tablename = 'TenantSetting' AND policyname = 'tenant_isolation'
|
|
23
|
+
) THEN
|
|
24
|
+
EXECUTE format(
|
|
25
|
+
'CREATE POLICY tenant_isolation ON "TenantSetting" USING ("tenantId" = current_setting(''app.current_tenant'', true))'
|
|
26
|
+
);
|
|
27
|
+
END IF;
|
|
28
|
+
END $$;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
-- Add slug to Project for human-readable URLs
|
|
2
|
+
ALTER TABLE "Project"
|
|
3
|
+
ADD COLUMN IF NOT EXISTS "slug" TEXT NOT NULL DEFAULT '';
|
|
4
|
+
|
|
5
|
+
-- Backfill: generate slug from existing name (lowercase, hyphens, strip special chars)
|
|
6
|
+
UPDATE "Project"
|
|
7
|
+
SET "slug" = LOWER(REGEXP_REPLACE(REGEXP_REPLACE(name, '[^a-zA-Z0-9\s-]', '', 'g'), '\s+', '-', 'g'))
|
|
8
|
+
WHERE "slug" = '';
|
|
9
|
+
|
|
10
|
+
-- Unique per tenant (duplicate names get suffix at the application layer)
|
|
11
|
+
CREATE UNIQUE INDEX IF NOT EXISTS "Project_tenantId_slug_key" ON "Project"("tenantId", "slug");
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
-- Add slug to Tenant for workspace URL identity
|
|
2
|
+
ALTER TABLE "Tenant"
|
|
3
|
+
ADD COLUMN IF NOT EXISTS "slug" TEXT NOT NULL DEFAULT '';
|
|
4
|
+
|
|
5
|
+
-- Backfill from name
|
|
6
|
+
UPDATE "Tenant"
|
|
7
|
+
SET "slug" = LOWER(REGEXP_REPLACE(REGEXP_REPLACE(name, '[^a-zA-Z0-9\s-]', '', 'g'), '\s+', '-', 'g'))
|
|
8
|
+
WHERE "slug" = '';
|
|
9
|
+
|
|
10
|
+
-- Make slugs unique (add suffix if needed via application layer)
|
|
11
|
+
CREATE UNIQUE INDEX IF NOT EXISTS "Tenant_slug_key" ON "Tenant"("slug");
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
-- Migration: 0011_oauth_connections
|
|
2
|
+
-- Add OAuthConnection model for GitHub App, Jira 3LO, Figma OAuth.
|
|
3
|
+
-- Replaces manual token entry (secretRef pattern in Connector).
|
|
4
|
+
-- All token fields are AES-256-GCM encrypted at application layer (_enc suffix).
|
|
5
|
+
|
|
6
|
+
CREATE TABLE "OAuthConnection" (
|
|
7
|
+
"id" TEXT NOT NULL,
|
|
8
|
+
"tenantId" TEXT NOT NULL,
|
|
9
|
+
"projectId" TEXT NOT NULL,
|
|
10
|
+
"provider" TEXT NOT NULL,
|
|
11
|
+
|
|
12
|
+
-- Encrypted token fields (AES-256-GCM, base64-encoded ciphertext)
|
|
13
|
+
"accessToken_enc" TEXT,
|
|
14
|
+
"refreshToken_enc" TEXT,
|
|
15
|
+
"tokenExpiresAt" TIMESTAMP(3),
|
|
16
|
+
"refreshTokenExpiresAt" TIMESTAMP(3),
|
|
17
|
+
|
|
18
|
+
-- Connection lifecycle
|
|
19
|
+
"status" TEXT NOT NULL DEFAULT 'CONNECTED',
|
|
20
|
+
"connectedAs" TEXT,
|
|
21
|
+
|
|
22
|
+
-- Provider-specific identifiers
|
|
23
|
+
"installationId" TEXT,
|
|
24
|
+
"cloudId" TEXT,
|
|
25
|
+
"scopes" TEXT,
|
|
26
|
+
|
|
27
|
+
-- Jira Data Center fallback (PAT + base URL)
|
|
28
|
+
"pat_enc" TEXT,
|
|
29
|
+
"dcBaseUrl" TEXT,
|
|
30
|
+
|
|
31
|
+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
32
|
+
"updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
33
|
+
|
|
34
|
+
CONSTRAINT "OAuthConnection_pkey" PRIMARY KEY ("id")
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
-- Enforce one active connection per provider per project
|
|
38
|
+
ALTER TABLE "OAuthConnection"
|
|
39
|
+
ADD CONSTRAINT "OAuthConnection_projectId_provider_key"
|
|
40
|
+
UNIQUE ("projectId", "provider");
|
|
41
|
+
|
|
42
|
+
-- Foreign key: project must exist
|
|
43
|
+
ALTER TABLE "OAuthConnection"
|
|
44
|
+
ADD CONSTRAINT "OAuthConnection_projectId_fkey"
|
|
45
|
+
FOREIGN KEY ("projectId") REFERENCES "Project"("id")
|
|
46
|
+
ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
47
|
+
|
|
48
|
+
-- Indexes for common query patterns
|
|
49
|
+
CREATE INDEX "OAuthConnection_tenantId_projectId_idx"
|
|
50
|
+
ON "OAuthConnection"("tenantId", "projectId");
|
|
51
|
+
|
|
52
|
+
CREATE INDEX "OAuthConnection_tenantId_provider_idx"
|
|
53
|
+
ON "OAuthConnection"("tenantId", "provider");
|
|
54
|
+
|
|
55
|
+
CREATE INDEX "OAuthConnection_status_idx"
|
|
56
|
+
ON "OAuthConnection"("status");
|
|
57
|
+
|
|
58
|
+
-- Row-Level Security: tenants may only see their own OAuth connections.
|
|
59
|
+
-- Mirrors the RLS policies applied to all other tenant-scoped tables.
|
|
60
|
+
ALTER TABLE "OAuthConnection" ENABLE ROW LEVEL SECURITY;
|
|
61
|
+
|
|
62
|
+
CREATE POLICY "tenant_isolation_oauth_connections"
|
|
63
|
+
ON "OAuthConnection"
|
|
64
|
+
USING ("tenantId" = current_setting('app.tenant_id', true));
|
|
65
|
+
|
|
66
|
+
-- Auto-update updatedAt on every row change
|
|
67
|
+
CREATE OR REPLACE FUNCTION update_oauth_connection_updated_at()
|
|
68
|
+
RETURNS TRIGGER AS $$
|
|
69
|
+
BEGIN
|
|
70
|
+
NEW."updatedAt" = CURRENT_TIMESTAMP;
|
|
71
|
+
RETURN NEW;
|
|
72
|
+
END;
|
|
73
|
+
$$ LANGUAGE plpgsql;
|
|
74
|
+
|
|
75
|
+
CREATE TRIGGER "OAuthConnection_updatedAt"
|
|
76
|
+
BEFORE UPDATE ON "OAuthConnection"
|
|
77
|
+
FOR EACH ROW
|
|
78
|
+
EXECUTE FUNCTION update_oauth_connection_updated_at();
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
-- Migration: 0012_agent_webhooks
|
|
2
|
+
-- Local agent pairing tokens (hashed) and outbound webhooks.
|
|
3
|
+
-- Token plain-text is only ever shown once on creation; we store SHA-256 hash.
|
|
4
|
+
-- Webhook HMAC secret is AES-256-GCM encrypted at application layer (_enc suffix).
|
|
5
|
+
|
|
6
|
+
CREATE TABLE "AgentToken" (
|
|
7
|
+
"id" TEXT NOT NULL,
|
|
8
|
+
"tenantId" TEXT NOT NULL,
|
|
9
|
+
"projectId" TEXT NOT NULL,
|
|
10
|
+
"name" TEXT NOT NULL,
|
|
11
|
+
"tokenHash" TEXT NOT NULL,
|
|
12
|
+
"lastSeenAt" TIMESTAMP(3),
|
|
13
|
+
"revokedAt" TIMESTAMP(3),
|
|
14
|
+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
15
|
+
|
|
16
|
+
CONSTRAINT "AgentToken_pkey" PRIMARY KEY ("id"),
|
|
17
|
+
CONSTRAINT "AgentToken_tokenHash_key" UNIQUE ("tokenHash"),
|
|
18
|
+
CONSTRAINT "AgentToken_projectId_fkey" FOREIGN KEY ("projectId") REFERENCES "Project"("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
CREATE TABLE "Webhook" (
|
|
22
|
+
"id" TEXT NOT NULL,
|
|
23
|
+
"tenantId" TEXT NOT NULL,
|
|
24
|
+
"projectId" TEXT NOT NULL,
|
|
25
|
+
"url" TEXT NOT NULL,
|
|
26
|
+
"secret_enc" TEXT NOT NULL,
|
|
27
|
+
"events" JSONB NOT NULL DEFAULT '[]',
|
|
28
|
+
"active" BOOLEAN NOT NULL DEFAULT true,
|
|
29
|
+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
30
|
+
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
31
|
+
|
|
32
|
+
CONSTRAINT "Webhook_pkey" PRIMARY KEY ("id"),
|
|
33
|
+
CONSTRAINT "Webhook_projectId_fkey" FOREIGN KEY ("projectId") REFERENCES "Project"("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
CREATE INDEX "AgentToken_tenantId_projectId_idx" ON "AgentToken"("tenantId", "projectId");
|
|
37
|
+
CREATE INDEX "Webhook_tenantId_projectId_idx" ON "Webhook"("tenantId", "projectId");
|
|
38
|
+
|
|
39
|
+
-- RLS: extend tenant isolation to new tables
|
|
40
|
+
ALTER TABLE "AgentToken" ENABLE ROW LEVEL SECURITY;
|
|
41
|
+
ALTER TABLE "Webhook" ENABLE ROW LEVEL SECURITY;
|
|
42
|
+
|
|
43
|
+
CREATE POLICY "tenant_isolation" ON "AgentToken"
|
|
44
|
+
USING ("tenantId" = current_setting('app.current_tenant', true));
|
|
45
|
+
CREATE POLICY "tenant_isolation" ON "Webhook"
|
|
46
|
+
USING ("tenantId" = current_setting('app.current_tenant', true));
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
-- Migration: 0013_project_artifacts
|
|
2
|
+
-- User-uploaded knowledge artifacts (docs, spreadsheets, old test cases).
|
|
3
|
+
-- Files are converted to markdown at upload time and stored as content.
|
|
4
|
+
-- Used by searchKnowledge() for keyword-scored RAG context assembly.
|
|
5
|
+
|
|
6
|
+
CREATE TABLE "ProjectArtifact" (
|
|
7
|
+
"id" TEXT NOT NULL,
|
|
8
|
+
"tenantId" TEXT NOT NULL,
|
|
9
|
+
"projectId" TEXT NOT NULL,
|
|
10
|
+
"name" TEXT NOT NULL,
|
|
11
|
+
"originalName" TEXT NOT NULL,
|
|
12
|
+
"mimeType" TEXT NOT NULL,
|
|
13
|
+
"size" INTEGER NOT NULL,
|
|
14
|
+
"content" TEXT NOT NULL,
|
|
15
|
+
"kind" TEXT NOT NULL DEFAULT 'DOCUMENT',
|
|
16
|
+
"uploadedBy" TEXT NOT NULL,
|
|
17
|
+
"uploadedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
18
|
+
|
|
19
|
+
CONSTRAINT "ProjectArtifact_pkey" PRIMARY KEY ("id"),
|
|
20
|
+
CONSTRAINT "ProjectArtifact_projectId_fkey" FOREIGN KEY ("projectId") REFERENCES "Project"("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
CREATE INDEX "ProjectArtifact_tenantId_projectId_idx" ON "ProjectArtifact"("tenantId", "projectId");
|
|
24
|
+
|
|
25
|
+
ALTER TABLE "ProjectArtifact" ENABLE ROW LEVEL SECURITY;
|
|
26
|
+
CREATE POLICY "tenant_isolation" ON "ProjectArtifact"
|
|
27
|
+
USING ("tenantId" = current_setting('app.current_tenant', true));
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
-- KnowledgeChunk: Postgres full-text search index for skill files and artifacts.
|
|
2
|
+
-- One row per heading-delimited section. The tsv column is maintained automatically
|
|
3
|
+
-- by Postgres via GENERATED ALWAYS AS; Prisma does not touch it.
|
|
4
|
+
|
|
5
|
+
CREATE TABLE "KnowledgeChunk" (
|
|
6
|
+
"id" TEXT NOT NULL DEFAULT gen_random_uuid()::TEXT,
|
|
7
|
+
"tenantId" TEXT NOT NULL,
|
|
8
|
+
"projectId" TEXT,
|
|
9
|
+
"sourceType" TEXT NOT NULL,
|
|
10
|
+
"sourceId" TEXT NOT NULL,
|
|
11
|
+
"heading" TEXT NOT NULL,
|
|
12
|
+
"content" TEXT NOT NULL,
|
|
13
|
+
"tsv" TSVECTOR GENERATED ALWAYS AS (
|
|
14
|
+
to_tsvector('english', "heading" || ' ' || "content")
|
|
15
|
+
) STORED,
|
|
16
|
+
"updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
17
|
+
|
|
18
|
+
CONSTRAINT "KnowledgeChunk_pkey" PRIMARY KEY ("id")
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
-- Composite index for tenant-scoped queries
|
|
22
|
+
CREATE INDEX "KnowledgeChunk_tenantId_projectId_idx" ON "KnowledgeChunk"("tenantId", "projectId");
|
|
23
|
+
|
|
24
|
+
-- Index for fast delete-by-source when re-indexing after skill file update
|
|
25
|
+
CREATE INDEX "KnowledgeChunk_sourceId_idx" ON "KnowledgeChunk"("sourceId");
|
|
26
|
+
|
|
27
|
+
-- GIN index on tsvector — the key index that makes ts_rank fast
|
|
28
|
+
CREATE INDEX "KnowledgeChunk_tsv_idx" ON "KnowledgeChunk" USING GIN("tsv");
|
|
29
|
+
|
|
30
|
+
-- Row-Level Security (same pattern as all other tables)
|
|
31
|
+
ALTER TABLE "KnowledgeChunk" ENABLE ROW LEVEL SECURITY;
|
|
32
|
+
|
|
33
|
+
CREATE POLICY "tenant_isolation" ON "KnowledgeChunk"
|
|
34
|
+
USING (
|
|
35
|
+
"tenantId" = current_setting('app.current_tenant', true)
|
|
36
|
+
OR "tenantId" = 'GLOBAL'
|
|
37
|
+
);
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Warnings:
|
|
3
|
+
|
|
4
|
+
- You are about to drop the `CrawlJob` table. If the table is not empty, all the data it contains will be lost.
|
|
5
|
+
|
|
6
|
+
*/
|
|
7
|
+
-- DropForeignKey
|
|
8
|
+
ALTER TABLE "CrawlJob" DROP CONSTRAINT "CrawlJob_projectId_fkey";
|
|
9
|
+
|
|
10
|
+
-- AlterTable
|
|
11
|
+
ALTER TABLE "OAuthConnection" ALTER COLUMN "updatedAt" DROP DEFAULT;
|
|
12
|
+
|
|
13
|
+
-- AlterTable
|
|
14
|
+
ALTER TABLE "TenantSetting" ALTER COLUMN "updatedAt" SET DATA TYPE TIMESTAMP(3);
|
|
15
|
+
|
|
16
|
+
-- DropTable
|
|
17
|
+
DROP TABLE "CrawlJob";
|
|
18
|
+
|
|
19
|
+
-- CreateTable
|
|
20
|
+
CREATE TABLE "PlatformJob" (
|
|
21
|
+
"id" TEXT NOT NULL,
|
|
22
|
+
"tenantId" TEXT NOT NULL,
|
|
23
|
+
"projectId" TEXT NOT NULL,
|
|
24
|
+
"type" TEXT NOT NULL DEFAULT 'CRAWL',
|
|
25
|
+
"status" TEXT NOT NULL DEFAULT 'QUEUED',
|
|
26
|
+
"config" JSONB NOT NULL,
|
|
27
|
+
"result" JSONB,
|
|
28
|
+
"error" TEXT,
|
|
29
|
+
"progress" INTEGER NOT NULL DEFAULT 0,
|
|
30
|
+
"queuedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
31
|
+
"startedAt" TIMESTAMP(3),
|
|
32
|
+
"finishedAt" TIMESTAMP(3),
|
|
33
|
+
|
|
34
|
+
CONSTRAINT "PlatformJob_pkey" PRIMARY KEY ("id")
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
-- CreateIndex
|
|
38
|
+
CREATE INDEX "PlatformJob_tenantId_projectId_idx" ON "PlatformJob"("tenantId", "projectId");
|
|
39
|
+
|
|
40
|
+
-- CreateIndex
|
|
41
|
+
CREATE INDEX "PlatformJob_status_idx" ON "PlatformJob"("status");
|
|
42
|
+
|
|
43
|
+
-- AddForeignKey
|
|
44
|
+
ALTER TABLE "PlatformJob" ADD CONSTRAINT "PlatformJob_projectId_fkey" FOREIGN KEY ("projectId") REFERENCES "Project"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Warnings:
|
|
3
|
+
|
|
4
|
+
- You are about to drop the column `tsv` on the `KnowledgeChunk` table. All the data in the column will be lost.
|
|
5
|
+
- Added the required column `isInteractive` to the `Element` table without a default value. This is not possible if the table is not empty.
|
|
6
|
+
|
|
7
|
+
*/
|
|
8
|
+
-- DropIndex
|
|
9
|
+
DROP INDEX "KnowledgeChunk_tsv_idx";
|
|
10
|
+
|
|
11
|
+
-- AlterTable (add nullable first so existing rows with nulls from failed prior attempt are handled)
|
|
12
|
+
ALTER TABLE "Element"
|
|
13
|
+
ADD COLUMN IF NOT EXISTS "isInteractive" BOOLEAN,
|
|
14
|
+
ADD COLUMN IF NOT EXISTS "text" TEXT,
|
|
15
|
+
ADD COLUMN IF NOT EXISTS "transitionsToScreenId" TEXT;
|
|
16
|
+
-- Backfill nulls before setting NOT NULL constraint
|
|
17
|
+
UPDATE "Element" SET "isInteractive" = false WHERE "isInteractive" IS NULL;
|
|
18
|
+
ALTER TABLE "Element" ALTER COLUMN "isInteractive" SET NOT NULL;
|
|
19
|
+
|
|
20
|
+
-- AlterTable
|
|
21
|
+
ALTER TABLE "KnowledgeChunk" DROP COLUMN "tsv",
|
|
22
|
+
ADD COLUMN "imagePath" TEXT,
|
|
23
|
+
ALTER COLUMN "id" DROP DEFAULT,
|
|
24
|
+
ALTER COLUMN "updatedAt" DROP DEFAULT;
|
|
25
|
+
|
|
26
|
+
-- AddForeignKey
|
|
27
|
+
ALTER TABLE "Element" ADD CONSTRAINT "Element_transitionsToScreenId_fkey" FOREIGN KEY ("transitionsToScreenId") REFERENCES "Screen"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
-- Restore the tsvector column + GIN index that was accidentally dropped by the
|
|
2
|
+
-- KAG schema migration (20260626053339). The tsv column is a GENERATED ALWAYS AS
|
|
3
|
+
-- STORED column managed by Postgres; Prisma declared it Unsupported so it will
|
|
4
|
+
-- never try to drop it again.
|
|
5
|
+
|
|
6
|
+
-- Restore GENERATED tsvector column
|
|
7
|
+
ALTER TABLE "KnowledgeChunk"
|
|
8
|
+
ADD COLUMN "tsv" TSVECTOR GENERATED ALWAYS AS (
|
|
9
|
+
to_tsvector('english', "heading" || ' ' || "content")
|
|
10
|
+
) STORED;
|
|
11
|
+
|
|
12
|
+
-- Restore GIN index for fast ts_rank scoring
|
|
13
|
+
CREATE INDEX "KnowledgeChunk_tsv_idx" ON "KnowledgeChunk" USING GIN("tsv");
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
-- AlterTable
|
|
4
|
+
ALTER TABLE "PlatformJob" ADD COLUMN "llmCallCount" INTEGER NOT NULL DEFAULT 0,
|
|
5
|
+
ADD COLUMN "totalCacheReadTokens" INTEGER,
|
|
6
|
+
ADD COLUMN "totalCompletionTokens" INTEGER,
|
|
7
|
+
ADD COLUMN "totalEstimatedCostUsd" DOUBLE PRECISION,
|
|
8
|
+
ADD COLUMN "totalPromptTokens" INTEGER;
|
|
9
|
+
|
|
10
|
+
-- AlterTable
|
|
11
|
+
ALTER TABLE "SkillFile" ADD COLUMN "lastGenAt" TIMESTAMP(3),
|
|
12
|
+
ADD COLUMN "lastGenCompletionTokens" INTEGER,
|
|
13
|
+
ADD COLUMN "lastGenCostUsd" DOUBLE PRECISION,
|
|
14
|
+
ADD COLUMN "lastGenModel" TEXT,
|
|
15
|
+
ADD COLUMN "lastGenPromptTokens" INTEGER;
|
|
16
|
+
|
|
17
|
+
-- AlterTable
|
|
18
|
+
ALTER TABLE "TestCase" ADD COLUMN "genCompletionTokens" INTEGER,
|
|
19
|
+
ADD COLUMN "genCostUsd" DOUBLE PRECISION,
|
|
20
|
+
ADD COLUMN "genModel" TEXT,
|
|
21
|
+
ADD COLUMN "genPromptTokens" INTEGER;
|
|
22
|
+
|
|
23
|
+
-- AlterTable
|
|
24
|
+
ALTER TABLE "TestSuite" ADD COLUMN "genAt" TIMESTAMP(3),
|
|
25
|
+
ADD COLUMN "genModel" TEXT,
|
|
26
|
+
ADD COLUMN "genScreenCount" INTEGER,
|
|
27
|
+
ADD COLUMN "genTotalCostUsd" DOUBLE PRECISION,
|
|
28
|
+
ADD COLUMN "genTotalTokens" INTEGER;
|
|
29
|
+
|
|
30
|
+
-- CreateTable
|
|
31
|
+
CREATE TABLE "LLMCallLog" (
|
|
32
|
+
"id" TEXT NOT NULL,
|
|
33
|
+
"tenantId" TEXT NOT NULL,
|
|
34
|
+
"projectId" TEXT,
|
|
35
|
+
"jobId" TEXT,
|
|
36
|
+
"agentType" TEXT NOT NULL,
|
|
37
|
+
"label" TEXT NOT NULL,
|
|
38
|
+
"entityId" TEXT,
|
|
39
|
+
"entityType" TEXT,
|
|
40
|
+
"provider" TEXT NOT NULL,
|
|
41
|
+
"model" TEXT NOT NULL,
|
|
42
|
+
"promptTokens" INTEGER NOT NULL,
|
|
43
|
+
"completionTokens" INTEGER NOT NULL,
|
|
44
|
+
"cacheReadTokens" INTEGER NOT NULL DEFAULT 0,
|
|
45
|
+
"cacheWriteTokens" INTEGER NOT NULL DEFAULT 0,
|
|
46
|
+
"totalTokens" INTEGER NOT NULL,
|
|
47
|
+
"estimatedCostUsd" DOUBLE PRECISION NOT NULL DEFAULT 0,
|
|
48
|
+
"outputTokens" INTEGER,
|
|
49
|
+
"latencyMs" INTEGER,
|
|
50
|
+
"calledAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
51
|
+
|
|
52
|
+
CONSTRAINT "LLMCallLog_pkey" PRIMARY KEY ("id")
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
-- CreateTable
|
|
56
|
+
CREATE TABLE "TokenBudget" (
|
|
57
|
+
"id" TEXT NOT NULL,
|
|
58
|
+
"tenantId" TEXT NOT NULL,
|
|
59
|
+
"monthlyTokenCap" INTEGER,
|
|
60
|
+
"monthlyUsdCap" DOUBLE PRECISION,
|
|
61
|
+
"alertAtPercent" INTEGER NOT NULL DEFAULT 80,
|
|
62
|
+
"currentMonthTokens" INTEGER NOT NULL DEFAULT 0,
|
|
63
|
+
"currentMonthUsd" DOUBLE PRECISION NOT NULL DEFAULT 0,
|
|
64
|
+
"lastResetAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
65
|
+
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
66
|
+
|
|
67
|
+
CONSTRAINT "TokenBudget_pkey" PRIMARY KEY ("id")
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
-- CreateIndex
|
|
71
|
+
CREATE INDEX "LLMCallLog_tenantId_projectId_idx" ON "LLMCallLog"("tenantId", "projectId");
|
|
72
|
+
|
|
73
|
+
-- CreateIndex
|
|
74
|
+
CREATE INDEX "LLMCallLog_tenantId_jobId_idx" ON "LLMCallLog"("tenantId", "jobId");
|
|
75
|
+
|
|
76
|
+
-- CreateIndex
|
|
77
|
+
CREATE INDEX "LLMCallLog_tenantId_agentType_idx" ON "LLMCallLog"("tenantId", "agentType");
|
|
78
|
+
|
|
79
|
+
-- CreateIndex
|
|
80
|
+
CREATE INDEX "LLMCallLog_entityId_idx" ON "LLMCallLog"("entityId");
|
|
81
|
+
|
|
82
|
+
-- CreateIndex
|
|
83
|
+
CREATE INDEX "LLMCallLog_calledAt_idx" ON "LLMCallLog"("calledAt");
|
|
84
|
+
|
|
85
|
+
-- CreateIndex
|
|
86
|
+
CREATE UNIQUE INDEX "TokenBudget_tenantId_key" ON "TokenBudget"("tenantId");
|