@trycompai/db 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (239) hide show
  1. package/dist/index.d.mts +9 -0
  2. package/dist/index.d.ts +9 -0
  3. package/dist/index.js +39 -0
  4. package/dist/index.mjs +14 -0
  5. package/dist/prisma/functionDefinition.sql +18 -0
  6. package/dist/prisma/migrations/20250403163138_init/migration.sql +611 -0
  7. package/dist/prisma/migrations/20250403165218_archived_on_its_own/migration.sql +29 -0
  8. package/dist/prisma/migrations/20250403194504_risk_assignee/migration.sql +18 -0
  9. package/dist/prisma/migrations/20250403201319_tasks_use_asignee/migration.sql +16 -0
  10. package/dist/prisma/migrations/20250403205655_vendor_assignee/migration.sql +22 -0
  11. package/dist/prisma/migrations/20250403205840_oops_optional/migration.sql +2 -0
  12. package/dist/prisma/migrations/20250403210049_task_assignee_optional_too/migration.sql +8 -0
  13. package/dist/prisma/migrations/20250404004853_stripecustomerid/migration.sql +2 -0
  14. package/dist/prisma/migrations/20250406004306_added_common_comment_table/migration.sql +20 -0
  15. package/dist/prisma/migrations/20250410193847_add_unique_constraint_to_artifact_t_table/migration.sql +30 -0
  16. package/dist/prisma/migrations/20250410193857_remove_published_field_from_evidence/migration.sql +12 -0
  17. package/dist/prisma/migrations/20250414191353_onboarding_experience/migration.sql +25 -0
  18. package/dist/prisma/migrations/20250414203443_added_evidence_to_onboarding/migration.sql +2 -0
  19. package/dist/prisma/migrations/20250417205622_add_global_vendors/migration.sql +26 -0
  20. package/dist/prisma/migrations/20250417205625_update_task_table_and_comments_and_attachments/migration.sql +86 -0
  21. package/dist/prisma/migrations/20250417205627_remove_evidence_table/migration.sql +109 -0
  22. package/dist/prisma/migrations/20250417205629_frequency_task_is_optional/migration.sql +2 -0
  23. package/dist/prisma/migrations/20250418151856_add_comment_relationship_to_attachment_and_vice_versa/migration.sql +8 -0
  24. package/dist/prisma/migrations/20250423154259_make_role_string/migration.sql +9 -0
  25. package/dist/prisma/migrations/20250424165055_update_onboarding_to_use_tasks/migration.sql +9 -0
  26. package/dist/prisma/migrations/20250424170518_remove_evidence_artifact_type/migration.sql +14 -0
  27. package/dist/prisma/migrations/20250428202144_add_website_to_organization/migration.sql +2 -0
  28. package/dist/prisma/migrations/20250429155419_add_company_details_to_onboarding/migration.sql +2 -0
  29. package/dist/prisma/migrations/20250509160401_added_framework_editor/migration.sql +8 -0
  30. package/dist/prisma/migrations/20250509162708_init_framework_editor_tables/migration.sql +122 -0
  31. package/dist/prisma/migrations/20250509172401_drop_slug/migration.sql +11 -0
  32. package/dist/prisma/migrations/20250509232122_trust_portal/migration.sql +24 -0
  33. package/dist/prisma/migrations/20250511040043_add_custom_domain_to_trust_portal/migration.sql +2 -0
  34. package/dist/prisma/migrations/20250511042943_trust_portal_domain_verified/migration.sql +2 -0
  35. package/dist/prisma/migrations/20250512004633_added_identifier/migration.sql +5 -0
  36. package/dist/prisma/migrations/20250512115717_added_framework_status/migration.sql +7 -0
  37. package/dist/prisma/migrations/20250512163351_add_contact_details_trust_portal/migration.sql +2 -0
  38. package/dist/prisma/migrations/20250514143147_remove_unique_constraint_on_integration_name/migration.sql +2 -0
  39. package/dist/prisma/migrations/20250514144228_add_vercel_check/migration.sql +2 -0
  40. package/dist/prisma/migrations/20250514150021_add_vercel_verification/migration.sql +2 -0
  41. package/dist/prisma/migrations/20250514161440_add_dates_to_framework_editor_tables/migration.sql +23 -0
  42. package/dist/prisma/migrations/20250515123635_trust_portal_friendly_url/migration.sql +21 -0
  43. package/dist/prisma/migrations/20250515124040_fix_trust_constraints/migration.sql +11 -0
  44. package/dist/prisma/migrations/20250516125758_patch_framework_id_in_editor/migration.sql +6 -0
  45. package/dist/prisma/migrations/20250516132431_add_many_to_many_support_to_tasks/migration.sql +69 -0
  46. package/dist/prisma/migrations/20250516142234_make_entity_optional/migration.sql +3 -0
  47. package/dist/prisma/migrations/20250516145149_drop_entity_and_entity_type/migration.sql +16 -0
  48. package/dist/prisma/migrations/20250516150558_drop_task_type/migration.sql +2 -0
  49. package/dist/prisma/migrations/20250516160714_insert_hardcoded_framework_to_db/migration.sql +37 -0
  50. package/dist/prisma/migrations/20250516161852_cast_framework_id_and_requirement_id_to_string/migration.sql +5 -0
  51. package/dist/prisma/migrations/20250516162324_convert_ids_to_new_format/migration.sql +31 -0
  52. package/dist/prisma/migrations/20250516162730_convert_framework_id/migration.sql +5 -0
  53. package/dist/prisma/migrations/20250516163156_added_relation_to_framework_and_requirement_maps/migration.sql +5 -0
  54. package/dist/prisma/migrations/20250516164307_drop_enums/migration.sql +5 -0
  55. package/dist/prisma/migrations/20250516194123_add_cal_option/migration.sql +2 -0
  56. package/dist/prisma/migrations/20250518133218_add_booking_details/migration.sql +2 -0
  57. package/dist/prisma/migrations/20250519141733_change_framework_id_to_string/migration.sql +3 -0
  58. package/dist/prisma/migrations/20250519141735_drop_enum_on_requirements_map/migration.sql +2 -0
  59. package/dist/prisma/migrations/20250519142913_add_template_references_to_instances/migration.sql +17 -0
  60. package/dist/prisma/migrations/20250519172353_drop_artifacts/migration.sql +56 -0
  61. package/dist/prisma/migrations/20250519204449_drop_relation_between_controls_and_framewrok_instance/migration.sql +14 -0
  62. package/dist/prisma/migrations/20250519212347_add_visibility_toggle_to_framework_editor/migration.sql +2 -0
  63. package/dist/prisma/migrations/20250520152548_add_approver_to_policy/migration.sql +5 -0
  64. package/dist/prisma/migrations/20250520175109_add_description_to_audit_log_for_convenience/migration.sql +2 -0
  65. package/dist/prisma/migrations/20250520175523_add_member_id_to_log_table/migration.sql +8 -0
  66. package/dist/prisma/migrations/20250521140239_add_entity_type_and_id_for_audit_logs_for_easy_filtering/migration.sql +9 -0
  67. package/dist/prisma/migrations/20250603135046_add_v2_onboarding_requirements/migration.sql +36 -0
  68. package/dist/prisma/migrations/20250604155610_add_job_id_column_to_onboarding/migration.sql +2 -0
  69. package/dist/prisma/migrations/20250605151521_make_framework_visibility_false/migration.sql +2 -0
  70. package/dist/prisma/migrations/20250605184738_add_cascade_to_entities_owned_by_org/migration.sql +29 -0
  71. package/dist/prisma/migrations/20250605184740_add_device_agent_details_to_org/migration.sql +18 -0
  72. package/dist/prisma/migrations/20250609130129_add_not_relevant/migration.sql +2 -0
  73. package/dist/prisma/migrations/20250610215328_add_fleet_label_to_employees/migration.sql +2 -0
  74. package/dist/prisma/migrations/20250611144654_add_is_fleet_setup_flag/migration.sql +2 -0
  75. package/dist/prisma/migrations/20250612160731_remove_unused_cols/migration.sql +10 -0
  76. package/dist/prisma/migrations/20250618001304_add_default_slug/migration.sql +3 -0
  77. package/dist/prisma/migrations/20250623184529_add_subscription_type/migration.sql +12 -0
  78. package/dist/prisma/migrations/20250626021946_add_starter_subscription_type/migration.sql +27 -0
  79. package/dist/prisma/migrations/20250626030206_added_new_subscription_type/migration.sql +2 -0
  80. package/dist/prisma/migrations/20250627180331_add_onboaridng_field/migration.sql +5 -0
  81. package/dist/prisma/migrations/20250627180828_rename_completed_col/migration.sql +15 -0
  82. package/dist/prisma/migrations/20250708152414_add_had_call_col/migration.sql +2 -0
  83. package/dist/prisma/migrations/20250711201749_update_retool_role_to_edit_had_call_column_in_organization_table/migration.sql +7 -0
  84. package/dist/prisma/migrations/20250711204234_add_read_permission_for_where_clause_on_retool_role/migration.sql +8 -0
  85. package/dist/prisma/migrations/20250714153009_remove_stripe_and_add_has_access/migration.sql +31 -0
  86. package/dist/prisma/migrations/20250715200054_add_perms_for_has_access_for_retool/migration.sql +7 -0
  87. package/dist/prisma/migrations/migration_lock.toml +3 -0
  88. package/dist/prisma/randomSecret.sql +12 -0
  89. package/dist/prisma/schema/attachments.prisma +35 -0
  90. package/dist/prisma/schema/auth.prisma +122 -0
  91. package/dist/prisma/schema/comment.prisma +27 -0
  92. package/dist/prisma/schema/context.prisma +18 -0
  93. package/dist/prisma/schema/control.prisma +21 -0
  94. package/dist/prisma/schema/framework-editor.prisma +96 -0
  95. package/dist/prisma/schema/framework.prisma +14 -0
  96. package/dist/prisma/schema/integration.prisma +32 -0
  97. package/dist/prisma/schema/onboarding.prisma +18 -0
  98. package/dist/prisma/schema/organization.prisma +34 -0
  99. package/dist/prisma/schema/policy.prisma +32 -0
  100. package/dist/prisma/schema/requirement.prisma +15 -0
  101. package/dist/prisma/schema/risk.prisma +57 -0
  102. package/dist/prisma/schema/shared.prisma +104 -0
  103. package/dist/prisma/schema/task.prisma +41 -0
  104. package/dist/prisma/schema/trust.prisma +37 -0
  105. package/dist/prisma/schema/vendor.prisma +56 -0
  106. package/dist/prisma/schema.prisma +12 -0
  107. package/dist/prisma/seed/frameworkEditorSchemas.js +136 -0
  108. package/dist/prisma/seed/frameworkEditorSchemas.ts +178 -0
  109. package/dist/prisma/seed/primitives/FrameworkEditorControlTemplate.json +296 -0
  110. package/dist/prisma/seed/primitives/FrameworkEditorFramework.json +101 -0
  111. package/dist/prisma/seed/primitives/FrameworkEditorPolicyTemplate.json +6057 -0
  112. package/dist/prisma/seed/primitives/FrameworkEditorRequirement.json +7841 -0
  113. package/dist/prisma/seed/primitives/FrameworkEditorTaskTemplate.json +308 -0
  114. package/dist/prisma/seed/primitives/FrameworkEditorVideo.json +47 -0
  115. package/dist/prisma/seed/relations/_FrameworkEditorControlTemplateToFrameworkEditorPolicyTemplate.json +178 -0
  116. package/dist/prisma/seed/relations/_FrameworkEditorControlTemplateToFrameworkEditorRequirement.json +470 -0
  117. package/dist/prisma/seed/relations/_FrameworkEditorControlTemplateToFrameworkEditorTaskTemplate.json +142 -0
  118. package/dist/prisma/seed/seed.js +160 -0
  119. package/dist/prisma/seed/seed.ts +192 -0
  120. package/dist/types.d.mts +1 -0
  121. package/dist/types.d.ts +1 -0
  122. package/dist/types.js +24 -0
  123. package/dist/types.mjs +2 -0
  124. package/package.json +75 -0
  125. package/prisma/functionDefinition.sql +18 -0
  126. package/prisma/migrations/20250403163138_init/migration.sql +611 -0
  127. package/prisma/migrations/20250403165218_archived_on_its_own/migration.sql +29 -0
  128. package/prisma/migrations/20250403194504_risk_assignee/migration.sql +18 -0
  129. package/prisma/migrations/20250403201319_tasks_use_asignee/migration.sql +16 -0
  130. package/prisma/migrations/20250403205655_vendor_assignee/migration.sql +22 -0
  131. package/prisma/migrations/20250403205840_oops_optional/migration.sql +2 -0
  132. package/prisma/migrations/20250403210049_task_assignee_optional_too/migration.sql +8 -0
  133. package/prisma/migrations/20250404004853_stripecustomerid/migration.sql +2 -0
  134. package/prisma/migrations/20250406004306_added_common_comment_table/migration.sql +20 -0
  135. package/prisma/migrations/20250410193847_add_unique_constraint_to_artifact_t_table/migration.sql +30 -0
  136. package/prisma/migrations/20250410193857_remove_published_field_from_evidence/migration.sql +12 -0
  137. package/prisma/migrations/20250414191353_onboarding_experience/migration.sql +25 -0
  138. package/prisma/migrations/20250414203443_added_evidence_to_onboarding/migration.sql +2 -0
  139. package/prisma/migrations/20250417205622_add_global_vendors/migration.sql +26 -0
  140. package/prisma/migrations/20250417205625_update_task_table_and_comments_and_attachments/migration.sql +86 -0
  141. package/prisma/migrations/20250417205627_remove_evidence_table/migration.sql +109 -0
  142. package/prisma/migrations/20250417205629_frequency_task_is_optional/migration.sql +2 -0
  143. package/prisma/migrations/20250418151856_add_comment_relationship_to_attachment_and_vice_versa/migration.sql +8 -0
  144. package/prisma/migrations/20250423154259_make_role_string/migration.sql +9 -0
  145. package/prisma/migrations/20250424165055_update_onboarding_to_use_tasks/migration.sql +9 -0
  146. package/prisma/migrations/20250424170518_remove_evidence_artifact_type/migration.sql +14 -0
  147. package/prisma/migrations/20250428202144_add_website_to_organization/migration.sql +2 -0
  148. package/prisma/migrations/20250429155419_add_company_details_to_onboarding/migration.sql +2 -0
  149. package/prisma/migrations/20250509160401_added_framework_editor/migration.sql +8 -0
  150. package/prisma/migrations/20250509162708_init_framework_editor_tables/migration.sql +122 -0
  151. package/prisma/migrations/20250509172401_drop_slug/migration.sql +11 -0
  152. package/prisma/migrations/20250509232122_trust_portal/migration.sql +24 -0
  153. package/prisma/migrations/20250511040043_add_custom_domain_to_trust_portal/migration.sql +2 -0
  154. package/prisma/migrations/20250511042943_trust_portal_domain_verified/migration.sql +2 -0
  155. package/prisma/migrations/20250512004633_added_identifier/migration.sql +5 -0
  156. package/prisma/migrations/20250512115717_added_framework_status/migration.sql +7 -0
  157. package/prisma/migrations/20250512163351_add_contact_details_trust_portal/migration.sql +2 -0
  158. package/prisma/migrations/20250514143147_remove_unique_constraint_on_integration_name/migration.sql +2 -0
  159. package/prisma/migrations/20250514144228_add_vercel_check/migration.sql +2 -0
  160. package/prisma/migrations/20250514150021_add_vercel_verification/migration.sql +2 -0
  161. package/prisma/migrations/20250514161440_add_dates_to_framework_editor_tables/migration.sql +23 -0
  162. package/prisma/migrations/20250515123635_trust_portal_friendly_url/migration.sql +21 -0
  163. package/prisma/migrations/20250515124040_fix_trust_constraints/migration.sql +11 -0
  164. package/prisma/migrations/20250516125758_patch_framework_id_in_editor/migration.sql +6 -0
  165. package/prisma/migrations/20250516132431_add_many_to_many_support_to_tasks/migration.sql +69 -0
  166. package/prisma/migrations/20250516142234_make_entity_optional/migration.sql +3 -0
  167. package/prisma/migrations/20250516145149_drop_entity_and_entity_type/migration.sql +16 -0
  168. package/prisma/migrations/20250516150558_drop_task_type/migration.sql +2 -0
  169. package/prisma/migrations/20250516160714_insert_hardcoded_framework_to_db/migration.sql +37 -0
  170. package/prisma/migrations/20250516161852_cast_framework_id_and_requirement_id_to_string/migration.sql +5 -0
  171. package/prisma/migrations/20250516162324_convert_ids_to_new_format/migration.sql +31 -0
  172. package/prisma/migrations/20250516162730_convert_framework_id/migration.sql +5 -0
  173. package/prisma/migrations/20250516163156_added_relation_to_framework_and_requirement_maps/migration.sql +5 -0
  174. package/prisma/migrations/20250516164307_drop_enums/migration.sql +5 -0
  175. package/prisma/migrations/20250516194123_add_cal_option/migration.sql +2 -0
  176. package/prisma/migrations/20250518133218_add_booking_details/migration.sql +2 -0
  177. package/prisma/migrations/20250519141733_change_framework_id_to_string/migration.sql +3 -0
  178. package/prisma/migrations/20250519141735_drop_enum_on_requirements_map/migration.sql +2 -0
  179. package/prisma/migrations/20250519142913_add_template_references_to_instances/migration.sql +17 -0
  180. package/prisma/migrations/20250519172353_drop_artifacts/migration.sql +56 -0
  181. package/prisma/migrations/20250519204449_drop_relation_between_controls_and_framewrok_instance/migration.sql +14 -0
  182. package/prisma/migrations/20250519212347_add_visibility_toggle_to_framework_editor/migration.sql +2 -0
  183. package/prisma/migrations/20250520152548_add_approver_to_policy/migration.sql +5 -0
  184. package/prisma/migrations/20250520175109_add_description_to_audit_log_for_convenience/migration.sql +2 -0
  185. package/prisma/migrations/20250520175523_add_member_id_to_log_table/migration.sql +8 -0
  186. package/prisma/migrations/20250521140239_add_entity_type_and_id_for_audit_logs_for_easy_filtering/migration.sql +9 -0
  187. package/prisma/migrations/20250603135046_add_v2_onboarding_requirements/migration.sql +36 -0
  188. package/prisma/migrations/20250604155610_add_job_id_column_to_onboarding/migration.sql +2 -0
  189. package/prisma/migrations/20250605151521_make_framework_visibility_false/migration.sql +2 -0
  190. package/prisma/migrations/20250605184738_add_cascade_to_entities_owned_by_org/migration.sql +29 -0
  191. package/prisma/migrations/20250605184740_add_device_agent_details_to_org/migration.sql +18 -0
  192. package/prisma/migrations/20250609130129_add_not_relevant/migration.sql +2 -0
  193. package/prisma/migrations/20250610215328_add_fleet_label_to_employees/migration.sql +2 -0
  194. package/prisma/migrations/20250611144654_add_is_fleet_setup_flag/migration.sql +2 -0
  195. package/prisma/migrations/20250612160731_remove_unused_cols/migration.sql +10 -0
  196. package/prisma/migrations/20250618001304_add_default_slug/migration.sql +3 -0
  197. package/prisma/migrations/20250623184529_add_subscription_type/migration.sql +12 -0
  198. package/prisma/migrations/20250626021946_add_starter_subscription_type/migration.sql +27 -0
  199. package/prisma/migrations/20250626030206_added_new_subscription_type/migration.sql +2 -0
  200. package/prisma/migrations/20250627180331_add_onboaridng_field/migration.sql +5 -0
  201. package/prisma/migrations/20250627180828_rename_completed_col/migration.sql +15 -0
  202. package/prisma/migrations/20250708152414_add_had_call_col/migration.sql +2 -0
  203. package/prisma/migrations/20250711201749_update_retool_role_to_edit_had_call_column_in_organization_table/migration.sql +7 -0
  204. package/prisma/migrations/20250711204234_add_read_permission_for_where_clause_on_retool_role/migration.sql +8 -0
  205. package/prisma/migrations/20250714153009_remove_stripe_and_add_has_access/migration.sql +31 -0
  206. package/prisma/migrations/20250715200054_add_perms_for_has_access_for_retool/migration.sql +7 -0
  207. package/prisma/migrations/migration_lock.toml +3 -0
  208. package/prisma/randomSecret.sql +12 -0
  209. package/prisma/schema/attachments.prisma +35 -0
  210. package/prisma/schema/auth.prisma +122 -0
  211. package/prisma/schema/comment.prisma +27 -0
  212. package/prisma/schema/context.prisma +18 -0
  213. package/prisma/schema/control.prisma +21 -0
  214. package/prisma/schema/framework-editor.prisma +96 -0
  215. package/prisma/schema/framework.prisma +14 -0
  216. package/prisma/schema/integration.prisma +32 -0
  217. package/prisma/schema/onboarding.prisma +18 -0
  218. package/prisma/schema/organization.prisma +34 -0
  219. package/prisma/schema/policy.prisma +32 -0
  220. package/prisma/schema/requirement.prisma +15 -0
  221. package/prisma/schema/risk.prisma +57 -0
  222. package/prisma/schema/shared.prisma +104 -0
  223. package/prisma/schema/task.prisma +41 -0
  224. package/prisma/schema/trust.prisma +37 -0
  225. package/prisma/schema/vendor.prisma +56 -0
  226. package/prisma/schema.prisma +12 -0
  227. package/prisma/seed/frameworkEditorSchemas.js +136 -0
  228. package/prisma/seed/frameworkEditorSchemas.ts +178 -0
  229. package/prisma/seed/primitives/FrameworkEditorControlTemplate.json +296 -0
  230. package/prisma/seed/primitives/FrameworkEditorFramework.json +101 -0
  231. package/prisma/seed/primitives/FrameworkEditorPolicyTemplate.json +6057 -0
  232. package/prisma/seed/primitives/FrameworkEditorRequirement.json +7841 -0
  233. package/prisma/seed/primitives/FrameworkEditorTaskTemplate.json +308 -0
  234. package/prisma/seed/primitives/FrameworkEditorVideo.json +47 -0
  235. package/prisma/seed/relations/_FrameworkEditorControlTemplateToFrameworkEditorPolicyTemplate.json +178 -0
  236. package/prisma/seed/relations/_FrameworkEditorControlTemplateToFrameworkEditorRequirement.json +470 -0
  237. package/prisma/seed/relations/_FrameworkEditorControlTemplateToFrameworkEditorTaskTemplate.json +142 -0
  238. package/prisma/seed/seed.js +160 -0
  239. package/prisma/seed/seed.ts +192 -0
@@ -0,0 +1,23 @@
1
+ -- AlterTable
2
+ ALTER TABLE "FrameworkEditorControlTemplate" ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
3
+ ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;
4
+
5
+ -- AlterTable
6
+ ALTER TABLE "FrameworkEditorFramework" ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
7
+ ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;
8
+
9
+ -- AlterTable
10
+ ALTER TABLE "FrameworkEditorPolicyTemplate" ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
11
+ ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;
12
+
13
+ -- AlterTable
14
+ ALTER TABLE "FrameworkEditorRequirement" ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
15
+ ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;
16
+
17
+ -- AlterTable
18
+ ALTER TABLE "FrameworkEditorTaskTemplate" ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
19
+ ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;
20
+
21
+ -- AlterTable
22
+ ALTER TABLE "FrameworkEditorVideo" ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
23
+ ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;
@@ -0,0 +1,21 @@
1
+ /*
2
+ Warnings:
3
+
4
+ - A unique constraint covering the columns `[friendlyUrl]` on the table `Trust` will be added. If there are existing duplicate values, this will fail.
5
+ - A unique constraint covering the columns `[organizationId,friendlyUrl]` on the table `Trust` will be added. If there are existing duplicate values, this will fail.
6
+
7
+ */
8
+ -- DropIndex
9
+ DROP INDEX "Trust_organizationId_key";
10
+
11
+ -- AlterTable
12
+ ALTER TABLE "Trust" ADD COLUMN "friendlyUrl" TEXT;
13
+
14
+ -- CreateIndex
15
+ CREATE UNIQUE INDEX "Trust_friendlyUrl_key" ON "Trust"("friendlyUrl");
16
+
17
+ -- CreateIndex
18
+ CREATE INDEX "Trust_friendlyUrl_idx" ON "Trust"("friendlyUrl");
19
+
20
+ -- CreateIndex
21
+ CREATE UNIQUE INDEX "Trust_organizationId_friendlyUrl_key" ON "Trust"("organizationId", "friendlyUrl");
@@ -0,0 +1,11 @@
1
+ /*
2
+ Warnings:
3
+
4
+ - A unique constraint covering the columns `[organizationId]` on the table `Trust` will be added. If there are existing duplicate values, this will fail.
5
+
6
+ */
7
+ -- DropIndex
8
+ DROP INDEX "Trust_organizationId_friendlyUrl_key";
9
+
10
+ -- CreateIndex
11
+ CREATE UNIQUE INDEX "Trust_organizationId_key" ON "Trust"("organizationId");
@@ -0,0 +1,6 @@
1
+ -- Update all references to SOC 2 framework IDs to the new ID in framework editor tables
2
+ -- Set new ID arbitrarily to frk_682734f304cbbfdb3a9d4f44
3
+
4
+ UPDATE "FrameworkEditorFramework"
5
+ SET "id" = 'frk_682734f304cbbfdb3a9d4f44'
6
+ WHERE "id" = 'soc2';
@@ -0,0 +1,69 @@
1
+ -- CreateTable
2
+ CREATE TABLE "_ControlToTask" (
3
+ "A" TEXT NOT NULL,
4
+ "B" TEXT NOT NULL,
5
+
6
+ CONSTRAINT "_ControlToTask_AB_pkey" PRIMARY KEY ("A","B")
7
+ );
8
+
9
+ -- CreateTable
10
+ CREATE TABLE "_RiskToTask" (
11
+ "A" TEXT NOT NULL,
12
+ "B" TEXT NOT NULL,
13
+
14
+ CONSTRAINT "_RiskToTask_AB_pkey" PRIMARY KEY ("A","B")
15
+ );
16
+
17
+ -- CreateTable
18
+ CREATE TABLE "_TaskToVendor" (
19
+ "A" TEXT NOT NULL,
20
+ "B" TEXT NOT NULL,
21
+
22
+ CONSTRAINT "_TaskToVendor_AB_pkey" PRIMARY KEY ("A","B")
23
+ );
24
+
25
+ -- CreateIndex
26
+ CREATE INDEX "_ControlToTask_B_index" ON "_ControlToTask"("B");
27
+
28
+ -- CreateIndex
29
+ CREATE INDEX "_RiskToTask_B_index" ON "_RiskToTask"("B");
30
+
31
+ -- CreateIndex
32
+ CREATE INDEX "_TaskToVendor_B_index" ON "_TaskToVendor"("B");
33
+
34
+ -- AddForeignKey
35
+ ALTER TABLE "_ControlToTask" ADD CONSTRAINT "_ControlToTask_A_fkey" FOREIGN KEY ("A") REFERENCES "Control"("id") ON DELETE CASCADE ON UPDATE CASCADE;
36
+
37
+ -- AddForeignKey
38
+ ALTER TABLE "_ControlToTask" ADD CONSTRAINT "_ControlToTask_B_fkey" FOREIGN KEY ("B") REFERENCES "Task"("id") ON DELETE CASCADE ON UPDATE CASCADE;
39
+
40
+ -- AddForeignKey
41
+ ALTER TABLE "_RiskToTask" ADD CONSTRAINT "_RiskToTask_A_fkey" FOREIGN KEY ("A") REFERENCES "Risk"("id") ON DELETE CASCADE ON UPDATE CASCADE;
42
+
43
+ -- AddForeignKey
44
+ ALTER TABLE "_RiskToTask" ADD CONSTRAINT "_RiskToTask_B_fkey" FOREIGN KEY ("B") REFERENCES "Task"("id") ON DELETE CASCADE ON UPDATE CASCADE;
45
+
46
+ -- AddForeignKey
47
+ ALTER TABLE "_TaskToVendor" ADD CONSTRAINT "_TaskToVendor_A_fkey" FOREIGN KEY ("A") REFERENCES "Task"("id") ON DELETE CASCADE ON UPDATE CASCADE;
48
+
49
+ -- AddForeignKey
50
+ ALTER TABLE "_TaskToVendor" ADD CONSTRAINT "_TaskToVendor_B_fkey" FOREIGN KEY ("B") REFERENCES "Vendor"("id") ON DELETE CASCADE ON UPDATE CASCADE;
51
+
52
+
53
+ -- Populate _ControlToTask from existing Task data
54
+ INSERT INTO "_ControlToTask" ("A", "B")
55
+ SELECT "entityId", "id"
56
+ FROM "Task"
57
+ WHERE "entityType" = 'control';
58
+
59
+ -- Populate _RiskToTask from existing Task data
60
+ INSERT INTO "_RiskToTask" ("A", "B")
61
+ SELECT "entityId", "id"
62
+ FROM "Task"
63
+ WHERE "entityType" = 'risk';
64
+
65
+ -- Populate _TaskToVendor from existing Task data
66
+ INSERT INTO "_TaskToVendor" ("A", "B")
67
+ SELECT "id", "entityId"
68
+ FROM "Task"
69
+ WHERE "entityType" = 'vendor';
@@ -0,0 +1,3 @@
1
+ -- AlterTable
2
+ ALTER TABLE "Task" ALTER COLUMN "entityId" DROP NOT NULL,
3
+ ALTER COLUMN "entityType" DROP NOT NULL;
@@ -0,0 +1,16 @@
1
+ /*
2
+ Warnings:
3
+
4
+ - You are about to drop the column `entityId` on the `Task` table. All the data in the column will be lost.
5
+ - You are about to drop the column `entityType` on the `Task` table. All the data in the column will be lost.
6
+
7
+ */
8
+ -- DropIndex
9
+ DROP INDEX "Task_entityId_idx";
10
+
11
+ -- DropIndex
12
+ DROP INDEX "Task_entityId_organizationId_idx";
13
+
14
+ -- AlterTable
15
+ ALTER TABLE "Task" DROP COLUMN "entityId",
16
+ DROP COLUMN "entityType";
@@ -0,0 +1,2 @@
1
+ -- DropEnum
2
+ DROP TYPE "TaskEntityType";
@@ -0,0 +1,37 @@
1
+ -- Insert SOC2 framework if it doesn't exist
2
+ INSERT INTO "FrameworkEditorFramework" (id, name, version, description, "createdAt", "updatedAt")
3
+ VALUES (
4
+ 'frk_682734f304cbbfdb3a9d4f44',
5
+ 'soc2',
6
+ '2025',
7
+ 'SOC 2 is a framework for assessing the security and reliability of information systems.',
8
+ NOW(),
9
+ NOW()
10
+ )
11
+ ON CONFLICT (id) DO NOTHING;
12
+
13
+ -- Insert SOC2 requirements if they don't exist
14
+ INSERT INTO "FrameworkEditorRequirement" (
15
+ id,
16
+ "frameworkId",
17
+ name,
18
+ identifier,
19
+ description,
20
+ "createdAt",
21
+ "updatedAt"
22
+ )
23
+ VALUES
24
+ ('frk_rq_681e8514778fd2238a33c121', 'frk_682734f304cbbfdb3a9d4f44', 'Commitment to Integrity and Ethical Values', 'CC1', 'This criterion ensures that the organization demonstrates commitment to integrity and ethical values, establishes board oversight, creates appropriate organizational structures, and shows commitment to competence.', NOW(), NOW()),
25
+ ('frk_rq_681e85140854c64019d53422', 'frk_682734f304cbbfdb3a9d4f44', 'Information Quality and Communication', 'CC2', 'This criterion focuses on how the organization obtains and uses relevant quality information to support the functioning of internal control, and communicates internal control information internally and externally.', NOW(), NOW()),
26
+ ('frk_rq_681e8514f62bb35319068677', 'frk_682734f304cbbfdb3a9d4f44', 'Risk Assessment and Management', 'CC3', 'This criterion evaluates how the organization specifies suitable objectives, identifies and analyzes risk, and assesses fraud risk and significant change that could impact the system of internal control.', NOW(), NOW()),
27
+ ('frk_rq_681e8514cba3ce1991f9d6c8', 'frk_682734f304cbbfdb3a9d4f44', 'Control Activities and Monitoring', 'CC4', 'This criterion assesses how the organization selects, develops and performs ongoing evaluations to determine whether controls are present and functioning, and communicates internal control deficiencies.', NOW(), NOW()),
28
+ ('frk_rq_681e85140e8b698d7154d43e', 'frk_682734f304cbbfdb3a9d4f44', 'Control Activities Implementation', 'CC5', 'This criterion evaluates how the organization selects and develops control activities that contribute to the mitigation of risks, and deploys them through policies and procedures.', NOW(), NOW()),
29
+ ('frk_rq_681e8514753b4054f1a632e7', 'frk_682734f304cbbfdb3a9d4f44', 'System Security Controls', 'CC6', 'This criterion focuses on how the organization implements controls over system boundaries, user identification and authentication, data security, and physical access to facilities and assets.', NOW(), NOW()),
30
+ ('frk_rq_681e851403a5c3114dc746ba', 'frk_682734f304cbbfdb3a9d4f44', 'System Operations Management', 'CC7', 'This criterion assesses how the organization manages system operations, detects and mitigates processing deviations, and implements recovery plans and business continuity procedures.', NOW(), NOW()),
31
+ ('frk_rq_681e85146ed80156122dd094', 'frk_682734f304cbbfdb3a9d4f44', 'Change Management', 'CC8', 'This criterion evaluates how the organization manages changes to infrastructure, data, software and procedures including change authorization and documentation.', NOW(), NOW()),
32
+ ('frk_rq_681e8514fedb1b2123661713', 'frk_682734f304cbbfdb3a9d4f44', 'Vendor and Business Continuity Risk Management', 'CC9', 'This criterion assesses how the organization identifies, selects and develops risk mitigation activities for risks arising from potential business disruptions and the use of vendors and business partners.', NOW(), NOW()),
33
+ ('frk_rq_681e8514b7a9c5278ada8527', 'frk_682734f304cbbfdb3a9d4f44', 'System Availability', 'A1', 'This criterion ensures that systems and data are available for operation and use as committed or agreed, including availability of information processing facilities and backup capabilities.', NOW(), NOW()),
34
+ ('frk_rq_681e85145df1606ef144c69c', 'frk_682734f304cbbfdb3a9d4f44', 'Processing Integrity', 'PI1', 'This criterion ensures that system processing is complete, valid, accurate, timely and authorized to meet the entity''s objectives.', NOW(), NOW()),
35
+ ('frk_rq_681e8514e2ebc08069c2c862', 'frk_682734f304cbbfdb3a9d4f44', 'Privacy Protection', 'P1', 'This criterion ensures that personal information is collected, used, retained, disclosed and disposed of in conformity with commitments in the entity''s privacy notice and criteria set forth in Generally Accepted Privacy Principles.', NOW(), NOW()),
36
+ ('frk_rq_681e8514ae9bac0ace4829ae', 'frk_682734f304cbbfdb3a9d4f44', 'Confidentiality Protection', 'C1', 'This criterion ensures that information designated as confidential is protected according to policy and procedures as committed or agreed, including encryption, access controls and secure disposal.', NOW(), NOW())
37
+ ON CONFLICT (id) DO NOTHING;
@@ -0,0 +1,5 @@
1
+ -- AlterTable
2
+ ALTER TABLE "FrameworkInstance" ALTER COLUMN "frameworkId" TYPE TEXT USING "frameworkId"::TEXT;
3
+
4
+ -- AlterTable
5
+ ALTER TABLE "RequirementMap" ALTER COLUMN "requirementId" TYPE TEXT USING "requirementId"::TEXT;
@@ -0,0 +1,31 @@
1
+ -- Migration: Convert RequirementMap.requirementId values to new format from soc2.map.txt
2
+
3
+ -- SOC2 requirementId mapping (old -> new)
4
+ -- soc2_CC1 -> frk_rq_681e8514778fd2238a33c121
5
+ -- soc2_CC2 -> frk_rq_681e85140854c64019d53422
6
+ -- soc2_CC3 -> frk_rq_681e8514f62bb35319068677
7
+ -- soc2_CC4 -> frk_rq_681e8514cba3ce1991f9d6c8
8
+ -- soc2_CC5 -> frk_rq_681e85140e8b698d7154d43e
9
+ -- soc2_CC6 -> frk_rq_681e8514753b4054f1a632e7
10
+ -- soc2_CC7 -> frk_rq_681e851403a5c3114dc746ba
11
+ -- soc2_CC8 -> frk_rq_681e85146ed80156122dd094
12
+ -- soc2_CC9 -> frk_rq_681e8514fedb1b2123661713
13
+ -- soc2_A1 -> frk_rq_681e8514b7a9c5278ada8527
14
+ -- soc2_PI1 -> frk_rq_681e85145df1606ef144c69c
15
+ -- soc2_P1 -> frk_rq_681e8514e2ebc08069c2c862
16
+ -- soc2_C1 -> frk_rq_681e8514ae9bac0ace4829ae
17
+
18
+ -- Update RequirementMap table for SOC2 requirements
19
+ UPDATE "RequirementMap" SET "requirementId" = 'frk_rq_681e8514778fd2238a33c121' WHERE "requirementId" = 'soc2_CC1';
20
+ UPDATE "RequirementMap" SET "requirementId" = 'frk_rq_681e85140854c64019d53422' WHERE "requirementId" = 'soc2_CC2';
21
+ UPDATE "RequirementMap" SET "requirementId" = 'frk_rq_681e8514f62bb35319068677' WHERE "requirementId" = 'soc2_CC3';
22
+ UPDATE "RequirementMap" SET "requirementId" = 'frk_rq_681e8514cba3ce1991f9d6c8' WHERE "requirementId" = 'soc2_CC4';
23
+ UPDATE "RequirementMap" SET "requirementId" = 'frk_rq_681e85140e8b698d7154d43e' WHERE "requirementId" = 'soc2_CC5';
24
+ UPDATE "RequirementMap" SET "requirementId" = 'frk_rq_681e8514753b4054f1a632e7' WHERE "requirementId" = 'soc2_CC6';
25
+ UPDATE "RequirementMap" SET "requirementId" = 'frk_rq_681e851403a5c3114dc746ba' WHERE "requirementId" = 'soc2_CC7';
26
+ UPDATE "RequirementMap" SET "requirementId" = 'frk_rq_681e85146ed80156122dd094' WHERE "requirementId" = 'soc2_CC8';
27
+ UPDATE "RequirementMap" SET "requirementId" = 'frk_rq_681e8514fedb1b2123661713' WHERE "requirementId" = 'soc2_CC9';
28
+ UPDATE "RequirementMap" SET "requirementId" = 'frk_rq_681e8514b7a9c5278ada8527' WHERE "requirementId" = 'soc2_A1';
29
+ UPDATE "RequirementMap" SET "requirementId" = 'frk_rq_681e85145df1606ef144c69c' WHERE "requirementId" = 'soc2_PI1';
30
+ UPDATE "RequirementMap" SET "requirementId" = 'frk_rq_681e8514e2ebc08069c2c862' WHERE "requirementId" = 'soc2_P1';
31
+ UPDATE "RequirementMap" SET "requirementId" = 'frk_rq_681e8514ae9bac0ace4829ae' WHERE "requirementId" = 'soc2_C1';
@@ -0,0 +1,5 @@
1
+ -- SOC2 requirementId mapping (old -> new)
2
+ -- soc2 -> frk_682734f304cbbfdb3a9d4f44
3
+
4
+ -- Update RequirementMap table for SOC2 requirements
5
+ UPDATE "FrameworkInstance" SET "frameworkId" = 'frk_682734f304cbbfdb3a9d4f44' WHERE "frameworkId" = 'soc2';
@@ -0,0 +1,5 @@
1
+ -- AddForeignKey
2
+ ALTER TABLE "FrameworkInstance" ADD CONSTRAINT "FrameworkInstance_frameworkId_fkey" FOREIGN KEY ("frameworkId") REFERENCES "FrameworkEditorFramework"("id") ON DELETE CASCADE ON UPDATE CASCADE;
3
+
4
+ -- AddForeignKey
5
+ ALTER TABLE "RequirementMap" ADD CONSTRAINT "RequirementMap_requirementId_fkey" FOREIGN KEY ("requirementId") REFERENCES "FrameworkEditorRequirement"("id") ON DELETE CASCADE ON UPDATE CASCADE;
@@ -0,0 +1,5 @@
1
+ -- DropEnum
2
+ DROP TYPE "FrameworkId";
3
+
4
+ -- DropEnum
5
+ DROP TYPE "RequirementId";
@@ -0,0 +1,2 @@
1
+ -- AlterTable
2
+ ALTER TABLE "Onboarding" ADD COLUMN "callBooked" BOOLEAN NOT NULL DEFAULT false;
@@ -0,0 +1,2 @@
1
+ -- AlterTable
2
+ ALTER TABLE "Onboarding" ADD COLUMN "companyBookingDetails" JSONB;
@@ -0,0 +1,3 @@
1
+
2
+ -- AlterTable
3
+ ALTER TABLE "FrameworkInstance" ALTER COLUMN "frameworkId" TYPE TEXT USING "frameworkId"::TEXT;
@@ -0,0 +1,2 @@
1
+ -- AlterTable
2
+ ALTER TABLE "RequirementMap" ALTER COLUMN "requirementId" TYPE TEXT USING "requirementId"::TEXT;
@@ -0,0 +1,17 @@
1
+ -- AlterTable
2
+ ALTER TABLE "Control" ADD COLUMN "controlTemplateId" TEXT;
3
+
4
+ -- AlterTable
5
+ ALTER TABLE "Policy" ADD COLUMN "policyTemplateId" TEXT;
6
+
7
+ -- AlterTable
8
+ ALTER TABLE "Task" ADD COLUMN "taskTemplateId" TEXT;
9
+
10
+ -- AddForeignKey
11
+ ALTER TABLE "Control" ADD CONSTRAINT "Control_controlTemplateId_fkey" FOREIGN KEY ("controlTemplateId") REFERENCES "FrameworkEditorControlTemplate"("id") ON DELETE SET NULL ON UPDATE CASCADE;
12
+
13
+ -- AddForeignKey
14
+ ALTER TABLE "Policy" ADD CONSTRAINT "Policy_policyTemplateId_fkey" FOREIGN KEY ("policyTemplateId") REFERENCES "FrameworkEditorPolicyTemplate"("id") ON DELETE SET NULL ON UPDATE CASCADE;
15
+
16
+ -- AddForeignKey
17
+ ALTER TABLE "Task" ADD CONSTRAINT "Task_taskTemplateId_fkey" FOREIGN KEY ("taskTemplateId") REFERENCES "FrameworkEditorTaskTemplate"("id") ON DELETE SET NULL ON UPDATE CASCADE;
@@ -0,0 +1,56 @@
1
+ /*
2
+ Warnings:
3
+
4
+ - You are about to drop the `Artifact` table. If the table is not empty, all the data it contains will be lost.
5
+ - You are about to drop the `_ArtifactToControl` table. If the table is not empty, all the data it contains will be lost.
6
+
7
+ */
8
+
9
+ -- CreateTable
10
+ CREATE TABLE "_ControlToPolicy" (
11
+ "A" TEXT NOT NULL,
12
+ "B" TEXT NOT NULL,
13
+
14
+ CONSTRAINT "_ControlToPolicy_AB_pkey" PRIMARY KEY ("A","B")
15
+ );
16
+
17
+ -- CreateIndex
18
+ CREATE INDEX "_ControlToPolicy_B_index" ON "_ControlToPolicy"("B");
19
+
20
+ -- AddForeignKey
21
+ ALTER TABLE "_ControlToPolicy" ADD CONSTRAINT "_ControlToPolicy_A_fkey" FOREIGN KEY ("A") REFERENCES "Control"("id") ON DELETE CASCADE ON UPDATE CASCADE;
22
+
23
+ -- AddForeignKey
24
+ ALTER TABLE "_ControlToPolicy" ADD CONSTRAINT "_ControlToPolicy_B_fkey" FOREIGN KEY ("B") REFERENCES "Policy"("id") ON DELETE CASCADE ON UPDATE CASCADE;
25
+
26
+ -- Manually copy relationships from Artifacts (that were linked to Policies) to Controls
27
+ -- into the new _ControlToPolicy table.
28
+ -- "A" in _ControlToPolicy is ControlId (from _ArtifactToControl."B")
29
+ -- "B" in _ControlToPolicy is PolicyId (from Artifact."policyId")
30
+ INSERT INTO "_ControlToPolicy" ("A", "B")
31
+ SELECT ATC."B", ART."policyId"
32
+ FROM "_ArtifactToControl" AS ATC
33
+ JOIN "Artifact" AS ART ON ATC."A" = ART."id"
34
+ WHERE ART."policyId" IS NOT NULL
35
+ ON CONFLICT ("A", "B") DO NOTHING;
36
+
37
+ -- DropForeignKey
38
+ ALTER TABLE "Artifact" DROP CONSTRAINT "Artifact_organizationId_fkey";
39
+
40
+ -- DropForeignKey
41
+ ALTER TABLE "Artifact" DROP CONSTRAINT "Artifact_policyId_fkey";
42
+
43
+ -- DropForeignKey
44
+ ALTER TABLE "_ArtifactToControl" DROP CONSTRAINT "_ArtifactToControl_A_fkey";
45
+
46
+ -- DropForeignKey
47
+ ALTER TABLE "_ArtifactToControl" DROP CONSTRAINT "_ArtifactToControl_B_fkey";
48
+
49
+ -- DropTable
50
+ DROP TABLE "Artifact";
51
+
52
+ -- DropTable
53
+ DROP TABLE "_ArtifactToControl";
54
+
55
+ -- DropEnum
56
+ DROP TYPE "ArtifactType";
@@ -0,0 +1,14 @@
1
+ /*
2
+ Warnings:
3
+
4
+ - You are about to drop the `_ControlToFrameworkInstance` table. If the table is not empty, all the data it contains will be lost.
5
+
6
+ */
7
+ -- DropForeignKey
8
+ ALTER TABLE "_ControlToFrameworkInstance" DROP CONSTRAINT "_ControlToFrameworkInstance_A_fkey";
9
+
10
+ -- DropForeignKey
11
+ ALTER TABLE "_ControlToFrameworkInstance" DROP CONSTRAINT "_ControlToFrameworkInstance_B_fkey";
12
+
13
+ -- DropTable
14
+ DROP TABLE "_ControlToFrameworkInstance";
@@ -0,0 +1,2 @@
1
+ -- AlterTable
2
+ ALTER TABLE "FrameworkEditorFramework" ADD COLUMN "visible" BOOLEAN NOT NULL DEFAULT true;
@@ -0,0 +1,5 @@
1
+ -- AlterTable
2
+ ALTER TABLE "Policy" ADD COLUMN "approverId" TEXT;
3
+
4
+ -- AddForeignKey
5
+ ALTER TABLE "Policy" ADD CONSTRAINT "Policy_approverId_fkey" FOREIGN KEY ("approverId") REFERENCES "Member"("id") ON DELETE SET NULL ON UPDATE CASCADE;
@@ -0,0 +1,2 @@
1
+ -- AlterTable
2
+ ALTER TABLE "AuditLog" ADD COLUMN "description" TEXT;
@@ -0,0 +1,8 @@
1
+ -- AlterTable
2
+ ALTER TABLE "AuditLog" ADD COLUMN "memberId" TEXT;
3
+
4
+ -- CreateIndex
5
+ CREATE INDEX "AuditLog_memberId_idx" ON "AuditLog"("memberId");
6
+
7
+ -- AddForeignKey
8
+ ALTER TABLE "AuditLog" ADD CONSTRAINT "AuditLog_memberId_fkey" FOREIGN KEY ("memberId") REFERENCES "Member"("id") ON DELETE CASCADE ON UPDATE CASCADE;
@@ -0,0 +1,9 @@
1
+ -- CreateEnum
2
+ CREATE TYPE "AuditLogEntityType" AS ENUM ('organization', 'framework', 'requirement', 'control', 'policy', 'task', 'people', 'risk', 'vendor', 'tests', 'integration');
3
+
4
+ -- AlterTable
5
+ ALTER TABLE "AuditLog" ADD COLUMN "entityId" TEXT,
6
+ ADD COLUMN "entityType" "AuditLogEntityType";
7
+
8
+ -- CreateIndex
9
+ CREATE INDEX "AuditLog_entityType_idx" ON "AuditLog"("entityType");
@@ -0,0 +1,36 @@
1
+ -- AlterTable
2
+ ALTER TABLE "Onboarding" ADD COLUMN "completed" BOOLEAN NOT NULL DEFAULT false;
3
+
4
+ -- AlterTable
5
+ ALTER TABLE "Onboarding" ALTER COLUMN "completed" SET DEFAULT true;
6
+
7
+ -- AlterTable
8
+ ALTER TABLE "Vendor" ADD COLUMN "website" TEXT;
9
+
10
+ -- CreateTable
11
+ CREATE TABLE "Context" (
12
+ "id" TEXT NOT NULL DEFAULT generate_prefixed_cuid('ctx'::text),
13
+ "organizationId" TEXT NOT NULL,
14
+ "question" TEXT NOT NULL,
15
+ "answer" TEXT NOT NULL,
16
+ "tags" TEXT[],
17
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
18
+ "updatedAt" TIMESTAMP(3) NOT NULL,
19
+
20
+ CONSTRAINT "Context_pkey" PRIMARY KEY ("id")
21
+ );
22
+
23
+ -- CreateIndex
24
+ CREATE INDEX "Context_organizationId_idx" ON "Context"("organizationId");
25
+
26
+ -- CreateIndex
27
+ CREATE INDEX "Context_question_idx" ON "Context"("question");
28
+
29
+ -- CreateIndex
30
+ CREATE INDEX "Context_answer_idx" ON "Context"("answer");
31
+
32
+ -- CreateIndex
33
+ CREATE INDEX "Context_tags_idx" ON "Context"("tags");
34
+
35
+ -- AddForeignKey
36
+ ALTER TABLE "Context" ADD CONSTRAINT "Context_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
@@ -0,0 +1,2 @@
1
+ -- AlterTable
2
+ ALTER TABLE "Onboarding" ADD COLUMN "triggerJobId" TEXT;
@@ -0,0 +1,2 @@
1
+ -- AlterTable
2
+ ALTER TABLE "FrameworkEditorFramework" ALTER COLUMN "visible" SET DEFAULT false;
@@ -0,0 +1,29 @@
1
+ -- DropForeignKey
2
+ ALTER TABLE "Attachment" DROP CONSTRAINT "Attachment_organizationId_fkey";
3
+
4
+ -- DropForeignKey
5
+ ALTER TABLE "Context" DROP CONSTRAINT "Context_organizationId_fkey";
6
+
7
+ -- DropForeignKey
8
+ ALTER TABLE "Onboarding" DROP CONSTRAINT "Onboarding_organizationId_fkey";
9
+
10
+ -- DropForeignKey
11
+ ALTER TABLE "Task" DROP CONSTRAINT "Task_organizationId_fkey";
12
+
13
+ -- DropForeignKey
14
+ ALTER TABLE "VendorContact" DROP CONSTRAINT "VendorContact_vendorId_fkey";
15
+
16
+ -- AddForeignKey
17
+ ALTER TABLE "Attachment" ADD CONSTRAINT "Attachment_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE CASCADE ON UPDATE CASCADE;
18
+
19
+ -- AddForeignKey
20
+ ALTER TABLE "Context" ADD CONSTRAINT "Context_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE CASCADE ON UPDATE CASCADE;
21
+
22
+ -- AddForeignKey
23
+ ALTER TABLE "Onboarding" ADD CONSTRAINT "Onboarding_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE CASCADE ON UPDATE CASCADE;
24
+
25
+ -- AddForeignKey
26
+ ALTER TABLE "Task" ADD CONSTRAINT "Task_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE CASCADE ON UPDATE CASCADE;
27
+
28
+ -- AddForeignKey
29
+ ALTER TABLE "VendorContact" ADD CONSTRAINT "VendorContact_vendorId_fkey" FOREIGN KEY ("vendorId") REFERENCES "Vendor"("id") ON DELETE CASCADE ON UPDATE CASCADE;
@@ -0,0 +1,18 @@
1
+ -- Create function to generate a random secret
2
+ CREATE OR REPLACE FUNCTION generate_random_secret(length integer DEFAULT 32)
3
+ RETURNS text AS $$
4
+ DECLARE
5
+ result text;
6
+ BEGIN
7
+ -- Generate random bytes and encode as hex
8
+ -- Using gen_random_bytes from pgcrypto extension
9
+ result = encode(gen_random_bytes(length), 'hex');
10
+ RETURN result;
11
+ END;
12
+ $$ LANGUAGE plpgsql;
13
+
14
+
15
+ -- AlterTable
16
+ ALTER TABLE "Organization" ADD COLUMN "fleetDmSecret" TEXT NOT NULL DEFAULT generate_random_secret(32);
17
+ ALTER TABLE "Organization" ADD COLUMN "fleetDmLabelId" INT;
18
+ ALTER TABLE "Organization" ADD COLUMN "osqueryAgentDownloadUrl" TEXT;
@@ -0,0 +1,2 @@
1
+ -- AlterEnum
2
+ ALTER TYPE "TaskStatus" ADD VALUE 'not_relevant';
@@ -0,0 +1,2 @@
1
+ -- AlterTable
2
+ ALTER TABLE "Member" ADD COLUMN "fleetDmLabelId" INTEGER;
@@ -0,0 +1,2 @@
1
+ -- AlterTable
2
+ ALTER TABLE "Organization" ADD COLUMN "isFleetSetupCompleted" BOOLEAN NOT NULL DEFAULT false;
@@ -0,0 +1,10 @@
1
+ /*
2
+ Warnings:
3
+
4
+ - You are about to drop the column `fleetDmSecret` on the `Organization` table. All the data in the column will be lost.
5
+ - You are about to drop the column `osqueryAgentDownloadUrl` on the `Organization` table. All the data in the column will be lost.
6
+
7
+ */
8
+ -- AlterTable
9
+ ALTER TABLE "Organization" DROP COLUMN "fleetDmSecret",
10
+ DROP COLUMN "osqueryAgentDownloadUrl";
@@ -0,0 +1,3 @@
1
+ -- AlterTable
2
+ ALTER TABLE "Organization" ALTER COLUMN "slug" SET DEFAULT generate_prefixed_cuid('slug'::text),
3
+ ALTER COLUMN "createdAt" SET DEFAULT CURRENT_TIMESTAMP;
@@ -0,0 +1,12 @@
1
+ -- CreateEnum
2
+ CREATE TYPE "SubscriptionType" AS ENUM ('NONE', 'SELF_SERVE', 'STRIPE');
3
+
4
+ -- AlterTable
5
+ ALTER TABLE "Organization" ADD COLUMN "stripeSubscriptionData" JSONB,
6
+ ADD COLUMN "subscriptionType" "SubscriptionType" NOT NULL DEFAULT 'NONE';
7
+
8
+ -- CreateIndex
9
+ CREATE INDEX "Organization_subscriptionType_idx" ON "Organization"("subscriptionType");
10
+
11
+ -- CreateIndex
12
+ CREATE INDEX "Organization_stripeCustomerId_idx" ON "Organization"("stripeCustomerId");
@@ -0,0 +1,27 @@
1
+ -- CreateEnum with new values
2
+ CREATE TYPE "SubscriptionType_new" AS ENUM ('NONE', 'FREE', 'STARTER', 'MANAGED');
3
+
4
+ -- AlterTable to add new column
5
+ ALTER TABLE "Organization" ADD COLUMN "subscriptionType_new" "SubscriptionType_new" NOT NULL DEFAULT 'NONE';
6
+
7
+ -- Transform data from old column to new column
8
+ UPDATE "Organization"
9
+ SET "subscriptionType_new" =
10
+ CASE
11
+ WHEN "subscriptionType" = 'NONE' THEN 'NONE'::"SubscriptionType_new"
12
+ WHEN "subscriptionType" = 'SELF_SERVE' THEN 'FREE'::"SubscriptionType_new"
13
+ WHEN "subscriptionType" = 'STRIPE' THEN 'MANAGED'::"SubscriptionType_new"
14
+ ELSE 'NONE'::"SubscriptionType_new"
15
+ END;
16
+
17
+ -- Drop the old column
18
+ ALTER TABLE "Organization" DROP COLUMN "subscriptionType";
19
+
20
+ -- Rename the new column to the old name
21
+ ALTER TABLE "Organization" RENAME COLUMN "subscriptionType_new" TO "subscriptionType";
22
+
23
+ -- Drop the old enum
24
+ DROP TYPE "SubscriptionType";
25
+
26
+ -- Rename the new enum to the old name
27
+ ALTER TYPE "SubscriptionType_new" RENAME TO "SubscriptionType";
@@ -0,0 +1,2 @@
1
+ -- CreateIndex
2
+ CREATE INDEX "Organization_subscriptionType_idx" ON "Organization"("subscriptionType");
@@ -0,0 +1,5 @@
1
+ -- AlterTable
2
+ ALTER TABLE "Organization" ADD COLUMN "onboardingCompleted" BOOLEAN NOT NULL DEFAULT false;
3
+
4
+ -- Update existing records to set onboardingCompleted to true
5
+ UPDATE "Organization" SET "onboardingCompleted" = true;
@@ -0,0 +1,15 @@
1
+ /*
2
+ Warnings:
3
+
4
+ - You are about to drop the column `completed` on the `Onboarding` table. All the data in the column will be lost.
5
+
6
+ */
7
+ -- AlterTable
8
+ ALTER TABLE "Onboarding"
9
+ ADD COLUMN IF NOT EXISTS "triggerJobCompleted" BOOLEAN NOT NULL DEFAULT false;
10
+
11
+ -- Copy existing values from completed to triggerJobCompleted
12
+ UPDATE "Onboarding" SET "triggerJobCompleted" = "completed";
13
+
14
+ -- Drop the old column
15
+ ALTER TABLE "Onboarding" DROP COLUMN "completed";
@@ -0,0 +1,2 @@
1
+ -- AlterTable
2
+ ALTER TABLE "Organization" ADD COLUMN "hadCall" BOOLEAN NOT NULL DEFAULT false;
@@ -0,0 +1,7 @@
1
+ DO $$
2
+ BEGIN
3
+ IF EXISTS (SELECT 1 FROM pg_roles WHERE rolname = 'retool_write') THEN
4
+ GRANT UPDATE ("hadCall") ON "Organization" TO retool_write;
5
+ END IF;
6
+ END
7
+ $$;
@@ -0,0 +1,8 @@
1
+ DO $$
2
+ BEGIN
3
+ IF EXISTS (SELECT 1 FROM pg_roles WHERE rolname = 'retool_write') THEN
4
+ -- Grant SELECT permission (needed for WHERE clause)
5
+ GRANT SELECT ON "Organization" TO retool_write;
6
+ END IF;
7
+ END
8
+ $$;