openship 0.1.0 → 0.1.7

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 (177) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.js +5786 -0
  3. package/dist/server/index.js +324319 -0
  4. package/dist/server/migrations/0000_init.sql +666 -0
  5. package/dist/server/migrations/0001_brief_tomorrow_man.sql +47 -0
  6. package/dist/server/migrations/0002_funny_dazzler.sql +2 -0
  7. package/dist/server/migrations/0003_third_killer_shrike.sql +1 -0
  8. package/dist/server/migrations/0004_session_active_org_not_null.sql +10 -0
  9. package/dist/server/migrations/0005_warm_amazoness.sql +3 -0
  10. package/dist/server/migrations/0006_lumpy_joystick.sql +1 -0
  11. package/dist/server/migrations/0007_outgoing_maginty.sql +2 -0
  12. package/dist/server/migrations/0008_frozen_cutover.sql +3 -0
  13. package/dist/server/migrations/0009_credits_billing.sql +142 -0
  14. package/dist/server/migrations/0010_credit_grant_dedupe.sql +14 -0
  15. package/dist/server/migrations/0011_remove_credit_ledger.sql +23 -0
  16. package/dist/server/migrations/0012_smart_deploys_and_git_rollback.sql +81 -0
  17. package/dist/server/migrations/0013_fix_check_run_rollup_unique.sql +38 -0
  18. package/dist/server/migrations/0014_default_rollback_git.sql +9 -0
  19. package/dist/server/migrations/0015_billing_idempotency_grants.sql +41 -0
  20. package/dist/server/migrations/0016_github_auth_high_findings.sql +30 -0
  21. package/dist/server/migrations/0017_spooky_rumiko_fujikawa.sql +6 -0
  22. package/dist/server/migrations/0018_calm_shatterstar.sql +1 -0
  23. package/dist/server/migrations/0019_rename_workspace_install_to_prepare.sql +1 -0
  24. package/dist/server/migrations/0020_uneven_the_renegades.sql +13 -0
  25. package/dist/server/migrations/0021_shiny_firestar.sql +2 -0
  26. package/dist/server/migrations/0022_version_on_success_backfill.sql +6 -0
  27. package/dist/server/migrations/0023_productive_gorilla_man.sql +17 -0
  28. package/dist/server/migrations/0024_sleepy_peter_quill.sql +2 -0
  29. package/dist/server/migrations/0025_smooth_blue_shield.sql +1 -0
  30. package/dist/server/migrations/0026_mail_backup_source.sql +11 -0
  31. package/dist/server/migrations/0027_opposite_anthem.sql +6 -0
  32. package/dist/server/migrations/0028_stale_rogue.sql +18 -0
  33. package/dist/server/migrations/0029_bouncy_loners.sql +16 -0
  34. package/dist/server/migrations/0030_bright_darkstar.sql +6 -0
  35. package/dist/server/migrations/0031_conscious_catseye.sql +13 -0
  36. package/dist/server/migrations/0032_wet_mimic.sql +51 -0
  37. package/dist/server/migrations/0033_eminent_molly_hayes.sql +2 -0
  38. package/dist/server/migrations/meta/0000_snapshot.json +5110 -0
  39. package/dist/server/migrations/meta/0001_snapshot.json +5257 -0
  40. package/dist/server/migrations/meta/0002_snapshot.json +5279 -0
  41. package/dist/server/migrations/meta/0003_snapshot.json +5286 -0
  42. package/dist/server/migrations/meta/0004_snapshot.json +5286 -0
  43. package/dist/server/migrations/meta/0005_snapshot.json +5305 -0
  44. package/dist/server/migrations/meta/0006_snapshot.json +5311 -0
  45. package/dist/server/migrations/meta/0007_snapshot.json +5323 -0
  46. package/dist/server/migrations/meta/0016_snapshot.json +6345 -0
  47. package/dist/server/migrations/meta/0017_snapshot.json +6383 -0
  48. package/dist/server/migrations/meta/0018_snapshot.json +6390 -0
  49. package/dist/server/migrations/meta/0019_snapshot.json +6390 -0
  50. package/dist/server/migrations/meta/0020_snapshot.json +6497 -0
  51. package/dist/server/migrations/meta/0021_snapshot.json +6509 -0
  52. package/dist/server/migrations/meta/0022_snapshot.json +6509 -0
  53. package/dist/server/migrations/meta/0023_snapshot.json +6629 -0
  54. package/dist/server/migrations/meta/0024_snapshot.json +6641 -0
  55. package/dist/server/migrations/meta/0025_snapshot.json +6648 -0
  56. package/dist/server/migrations/meta/0026_snapshot.json +6750 -0
  57. package/dist/server/migrations/meta/0027_snapshot.json +6757 -0
  58. package/dist/server/migrations/meta/0028_snapshot.json +6895 -0
  59. package/dist/server/migrations/meta/0029_snapshot.json +7028 -0
  60. package/dist/server/migrations/meta/0030_snapshot.json +7066 -0
  61. package/dist/server/migrations/meta/0031_snapshot.json +7181 -0
  62. package/dist/server/migrations/meta/0032_snapshot.json +7570 -0
  63. package/dist/server/migrations/meta/0033_snapshot.json +7597 -0
  64. package/dist/server/migrations/meta/_journal.json +244 -0
  65. package/dist/server/pglite/pglite.data +0 -0
  66. package/dist/server/pglite/pglite.wasm +0 -0
  67. package/package.json +33 -21
  68. package/.env.example +0 -22
  69. package/.nvmrc +0 -1
  70. package/.prettierrc +0 -7
  71. package/CONTRIBUTING.md +0 -40
  72. package/README.md +0 -164
  73. package/apps/api/.env.example +0 -30
  74. package/apps/api/Dockerfile +0 -24
  75. package/apps/api/package.json +0 -37
  76. package/apps/api/src/app.ts +0 -26
  77. package/apps/api/src/config/env.ts +0 -39
  78. package/apps/api/src/config/index.ts +0 -1
  79. package/apps/api/src/index.ts +0 -8
  80. package/apps/api/src/middleware/auth.ts +0 -24
  81. package/apps/api/src/middleware/error-handler.ts +0 -21
  82. package/apps/api/src/middleware/index.ts +0 -3
  83. package/apps/api/src/middleware/rate-limiter.ts +0 -26
  84. package/apps/api/src/modules/auth/auth.controller.ts +0 -26
  85. package/apps/api/src/modules/auth/auth.routes.ts +0 -10
  86. package/apps/api/src/modules/auth/auth.schema.ts +0 -12
  87. package/apps/api/src/modules/auth/auth.service.ts +0 -23
  88. package/apps/api/src/modules/billing/billing.controller.ts +0 -60
  89. package/apps/api/src/modules/billing/billing.routes.ts +0 -26
  90. package/apps/api/src/modules/billing/billing.schema.ts +0 -9
  91. package/apps/api/src/modules/billing/billing.service.ts +0 -33
  92. package/apps/api/src/modules/deployments/deployment.controller.ts +0 -35
  93. package/apps/api/src/modules/deployments/deployment.routes.ts +0 -11
  94. package/apps/api/src/modules/deployments/deployment.schema.ts +0 -7
  95. package/apps/api/src/modules/deployments/deployment.service.ts +0 -23
  96. package/apps/api/src/modules/domains/domain.controller.ts +0 -21
  97. package/apps/api/src/modules/domains/domain.routes.ts +0 -9
  98. package/apps/api/src/modules/domains/domain.service.ts +0 -19
  99. package/apps/api/src/modules/health/health.routes.ts +0 -10
  100. package/apps/api/src/modules/projects/project.controller.ts +0 -29
  101. package/apps/api/src/modules/projects/project.routes.ts +0 -10
  102. package/apps/api/src/modules/projects/project.schema.ts +0 -9
  103. package/apps/api/src/modules/projects/project.service.ts +0 -23
  104. package/apps/api/src/modules/webhooks/webhook.controller.ts +0 -22
  105. package/apps/api/src/modules/webhooks/webhook.routes.ts +0 -12
  106. package/apps/api/src/modules/webhooks/webhook.service.ts +0 -11
  107. package/apps/api/tsconfig.json +0 -12
  108. package/apps/cli/package.json +0 -28
  109. package/apps/cli/src/commands/deploy.ts +0 -11
  110. package/apps/cli/src/commands/init.ts +0 -8
  111. package/apps/cli/src/commands/login.ts +0 -8
  112. package/apps/cli/src/commands/logs.ts +0 -9
  113. package/apps/cli/src/index.ts +0 -21
  114. package/apps/cli/src/lib/api-client.ts +0 -35
  115. package/apps/cli/tsconfig.json +0 -12
  116. package/apps/dashboard/Dockerfile +0 -24
  117. package/apps/dashboard/next.config.mjs +0 -6
  118. package/apps/dashboard/package.json +0 -28
  119. package/apps/dashboard/src/app/(auth)/layout.tsx +0 -6
  120. package/apps/dashboard/src/app/(auth)/login/page.tsx +0 -11
  121. package/apps/dashboard/src/app/(auth)/register/page.tsx +0 -10
  122. package/apps/dashboard/src/app/(dashboard)/billing/page.tsx +0 -10
  123. package/apps/dashboard/src/app/(dashboard)/deployments/page.tsx +0 -8
  124. package/apps/dashboard/src/app/(dashboard)/domains/page.tsx +0 -8
  125. package/apps/dashboard/src/app/(dashboard)/layout.tsx +0 -37
  126. package/apps/dashboard/src/app/(dashboard)/monitoring/page.tsx +0 -8
  127. package/apps/dashboard/src/app/(dashboard)/projects/page.tsx +0 -8
  128. package/apps/dashboard/src/app/(dashboard)/settings/page.tsx +0 -8
  129. package/apps/dashboard/src/app/globals.css +0 -3
  130. package/apps/dashboard/src/app/layout.tsx +0 -15
  131. package/apps/dashboard/src/app/page.tsx +0 -6
  132. package/apps/dashboard/tsconfig.json +0 -11
  133. package/apps/web/Dockerfile +0 -24
  134. package/apps/web/next.config.mjs +0 -6
  135. package/apps/web/package.json +0 -26
  136. package/apps/web/src/app/(marketing)/docs/page.tsx +0 -10
  137. package/apps/web/src/app/(marketing)/layout.tsx +0 -24
  138. package/apps/web/src/app/(marketing)/page.tsx +0 -2
  139. package/apps/web/src/app/(marketing)/pricing/page.tsx +0 -10
  140. package/apps/web/src/app/globals.css +0 -3
  141. package/apps/web/src/app/layout.tsx +0 -16
  142. package/apps/web/src/app/page.tsx +0 -10
  143. package/apps/web/tsconfig.json +0 -11
  144. package/docker-compose.yml +0 -87
  145. package/packages/adapters/package.json +0 -27
  146. package/packages/adapters/src/base-adapter.ts +0 -49
  147. package/packages/adapters/src/docker-adapter.ts +0 -43
  148. package/packages/adapters/src/index.ts +0 -4
  149. package/packages/adapters/src/oblien-adapter.ts +0 -46
  150. package/packages/adapters/src/registry.ts +0 -22
  151. package/packages/adapters/tsconfig.json +0 -9
  152. package/packages/core/package.json +0 -27
  153. package/packages/core/src/constants.ts +0 -28
  154. package/packages/core/src/errors.ts +0 -49
  155. package/packages/core/src/index.ts +0 -4
  156. package/packages/core/src/types.ts +0 -47
  157. package/packages/core/src/utils.ts +0 -35
  158. package/packages/core/tsconfig.json +0 -9
  159. package/packages/db/package.json +0 -32
  160. package/packages/db/prisma/schema.prisma +0 -160
  161. package/packages/db/src/index.ts +0 -11
  162. package/packages/db/tsconfig.json +0 -9
  163. package/packages/ui/package.json +0 -38
  164. package/packages/ui/src/components/badge.tsx +0 -29
  165. package/packages/ui/src/components/button.tsx +0 -44
  166. package/packages/ui/src/components/card.tsx +0 -26
  167. package/packages/ui/src/components/status-dot.tsx +0 -25
  168. package/packages/ui/src/globals.css +0 -18
  169. package/packages/ui/src/index.tsx +0 -8
  170. package/packages/ui/src/lib/cn.ts +0 -7
  171. package/packages/ui/tsconfig.json +0 -9
  172. package/pnpm-workspace.yaml +0 -4
  173. package/tooling/tsconfig/base.json +0 -19
  174. package/tooling/tsconfig/nextjs.json +0 -10
  175. package/tooling/tsconfig/node.json +0 -10
  176. package/tooling/tsconfig/package.json +0 -7
  177. package/turbo.json +0 -32
@@ -0,0 +1,666 @@
1
+ CREATE TABLE "account" (
2
+ "id" text PRIMARY KEY NOT NULL,
3
+ "account_id" text NOT NULL,
4
+ "provider_id" text NOT NULL,
5
+ "user_id" text NOT NULL,
6
+ "access_token" text,
7
+ "refresh_token" text,
8
+ "id_token" text,
9
+ "access_token_expires_at" timestamp,
10
+ "refresh_token_expires_at" timestamp,
11
+ "scope" text,
12
+ "password" text,
13
+ "created_at" timestamp DEFAULT now() NOT NULL,
14
+ "updated_at" timestamp DEFAULT now() NOT NULL
15
+ );
16
+ --> statement-breakpoint
17
+ CREATE TABLE "audit_event" (
18
+ "id" text PRIMARY KEY NOT NULL,
19
+ "organization_id" text NOT NULL,
20
+ "actor_user_id" text,
21
+ "event_type" text NOT NULL,
22
+ "resource_type" text,
23
+ "resource_id" text,
24
+ "before" jsonb,
25
+ "after" jsonb,
26
+ "ip_address" text,
27
+ "user_agent" text,
28
+ "created_at" timestamp DEFAULT now() NOT NULL
29
+ );
30
+ --> statement-breakpoint
31
+ CREATE TABLE "backup_destination" (
32
+ "id" text PRIMARY KEY NOT NULL,
33
+ "organization_id" text NOT NULL,
34
+ "name" text NOT NULL,
35
+ "kind" text NOT NULL,
36
+ "server_id" text,
37
+ "endpoint" text,
38
+ "region" text,
39
+ "bucket" text,
40
+ "path_prefix" text,
41
+ "ssh_host" text,
42
+ "ssh_port" integer,
43
+ "ssh_user" text,
44
+ "access_key_id_enc" text,
45
+ "secret_access_key_enc" text,
46
+ "sftp_password_enc" text,
47
+ "sftp_private_key_enc" text,
48
+ "sftp_key_passphrase_enc" text,
49
+ "last_verified_at" timestamp,
50
+ "last_verify_error" text,
51
+ "is_default" boolean DEFAULT false NOT NULL,
52
+ "deleted_at" timestamp,
53
+ "created_at" timestamp DEFAULT now() NOT NULL,
54
+ "updated_at" timestamp DEFAULT now() NOT NULL
55
+ );
56
+ --> statement-breakpoint
57
+ CREATE TABLE "backup_policy" (
58
+ "id" text PRIMARY KEY NOT NULL,
59
+ "project_id" text NOT NULL,
60
+ "service_id" text,
61
+ "destination_id" text NOT NULL,
62
+ "enabled" boolean DEFAULT true NOT NULL,
63
+ "cron_expression" text,
64
+ "trigger_on_pre_deploy" boolean DEFAULT false NOT NULL,
65
+ "webhook_token" text,
66
+ "webhook_last_fired_at" timestamp,
67
+ "retain_count" integer,
68
+ "retain_days" integer,
69
+ "payload_kind" text DEFAULT 'auto' NOT NULL,
70
+ "payload_config" jsonb DEFAULT '{}'::jsonb,
71
+ "pre_hook" text,
72
+ "post_hook" text,
73
+ "hook_timeout_seconds" integer DEFAULT 300 NOT NULL,
74
+ "compression_algo" text DEFAULT 'zstd' NOT NULL,
75
+ "encryption_at_rest" boolean DEFAULT false NOT NULL,
76
+ "created_by" text,
77
+ "deleted_at" timestamp,
78
+ "created_at" timestamp DEFAULT now() NOT NULL,
79
+ "updated_at" timestamp DEFAULT now() NOT NULL
80
+ );
81
+ --> statement-breakpoint
82
+ CREATE TABLE "backup_restore" (
83
+ "id" text PRIMARY KEY NOT NULL,
84
+ "run_id" text NOT NULL,
85
+ "destination_id" text NOT NULL,
86
+ "project_id" text,
87
+ "service_id" text,
88
+ "organization_id" text NOT NULL,
89
+ "status" text DEFAULT 'queued' NOT NULL,
90
+ "mode" text DEFAULT 'in_place' NOT NULL,
91
+ "fork_service_id" text,
92
+ "started_at" timestamp DEFAULT now() NOT NULL,
93
+ "finished_at" timestamp,
94
+ "last_event_at" timestamp DEFAULT now() NOT NULL,
95
+ "bytes_restored" bigint,
96
+ "error_message" text,
97
+ "client_ip" text,
98
+ "confirmation_token" text
99
+ );
100
+ --> statement-breakpoint
101
+ CREATE TABLE "backup_run" (
102
+ "id" text PRIMARY KEY NOT NULL,
103
+ "policy_id" text,
104
+ "destination_id" text,
105
+ "project_id" text,
106
+ "service_id" text,
107
+ "organization_id" text NOT NULL,
108
+ "status" text DEFAULT 'queued' NOT NULL,
109
+ "triggered_by" text NOT NULL,
110
+ "triggered_by_user_id" text,
111
+ "client_ip" text,
112
+ "started_at" timestamp DEFAULT now() NOT NULL,
113
+ "finished_at" timestamp,
114
+ "last_event_at" timestamp DEFAULT now() NOT NULL,
115
+ "object_key_prefix" text,
116
+ "manifest_key" text,
117
+ "bytes_transferred" bigint,
118
+ "artifacts" jsonb DEFAULT '[]'::jsonb,
119
+ "error_message" text,
120
+ "hook_log" text,
121
+ "retention_locked_until" timestamp,
122
+ "deleted_at" timestamp
123
+ );
124
+ --> statement-breakpoint
125
+ CREATE TABLE "build_session" (
126
+ "id" text PRIMARY KEY NOT NULL,
127
+ "deployment_id" text NOT NULL,
128
+ "project_id" text NOT NULL,
129
+ "status" text DEFAULT 'queued' NOT NULL,
130
+ "logs" jsonb,
131
+ "duration_ms" integer,
132
+ "started_at" timestamp,
133
+ "finished_at" timestamp,
134
+ "created_at" timestamp DEFAULT now() NOT NULL
135
+ );
136
+ --> statement-breakpoint
137
+ CREATE TABLE "cloud_handoff_code" (
138
+ "code" text PRIMARY KEY NOT NULL,
139
+ "user_data" jsonb NOT NULL,
140
+ "session_token" text NOT NULL,
141
+ "code_challenge" text,
142
+ "expires_at" timestamp NOT NULL,
143
+ "created_at" timestamp DEFAULT now() NOT NULL
144
+ );
145
+ --> statement-breakpoint
146
+ CREATE TABLE "deployment" (
147
+ "id" text PRIMARY KEY NOT NULL,
148
+ "project_id" text NOT NULL,
149
+ "organization_id" text NOT NULL,
150
+ "branch" text NOT NULL,
151
+ "commit_sha" text,
152
+ "commit_message" text,
153
+ "trigger" text DEFAULT 'manual' NOT NULL,
154
+ "environment" text DEFAULT 'production' NOT NULL,
155
+ "framework" text,
156
+ "status" text DEFAULT 'queued' NOT NULL,
157
+ "image_ref" text,
158
+ "build_duration_ms" integer,
159
+ "container_id" text,
160
+ "url" text,
161
+ "meta" jsonb,
162
+ "env_vars" jsonb,
163
+ "error_message" text,
164
+ "artifact_retained_at" timestamp,
165
+ "pinned" boolean DEFAULT false NOT NULL,
166
+ "created_at" timestamp DEFAULT now() NOT NULL,
167
+ "updated_at" timestamp DEFAULT now() NOT NULL
168
+ );
169
+ --> statement-breakpoint
170
+ CREATE TABLE "domain" (
171
+ "id" text PRIMARY KEY NOT NULL,
172
+ "project_id" text NOT NULL,
173
+ "service_id" text,
174
+ "hostname" text NOT NULL,
175
+ "target_port" integer,
176
+ "target_path" text,
177
+ "domain_type" text,
178
+ "is_primary" boolean DEFAULT false NOT NULL,
179
+ "status" text DEFAULT 'pending' NOT NULL,
180
+ "verification_token" text,
181
+ "verified" boolean DEFAULT false NOT NULL,
182
+ "verified_at" timestamp,
183
+ "ssl_status" text DEFAULT 'none' NOT NULL,
184
+ "ssl_issuer" text,
185
+ "ssl_expires_at" timestamp,
186
+ "created_at" timestamp DEFAULT now() NOT NULL,
187
+ "updated_at" timestamp DEFAULT now() NOT NULL,
188
+ CONSTRAINT "domain_hostname_unique" UNIQUE("hostname")
189
+ );
190
+ --> statement-breakpoint
191
+ CREATE TABLE "env_var" (
192
+ "id" text PRIMARY KEY NOT NULL,
193
+ "project_id" text NOT NULL,
194
+ "service_id" text,
195
+ "key" text NOT NULL,
196
+ "value" text NOT NULL,
197
+ "environment" text DEFAULT 'production' NOT NULL,
198
+ "is_secret" boolean DEFAULT false NOT NULL,
199
+ "created_at" timestamp DEFAULT now() NOT NULL,
200
+ "updated_at" timestamp DEFAULT now() NOT NULL
201
+ );
202
+ --> statement-breakpoint
203
+ CREATE TABLE "git_installation" (
204
+ "id" text PRIMARY KEY NOT NULL,
205
+ "user_id" text NOT NULL,
206
+ "organization_id" text NOT NULL,
207
+ "provider" text DEFAULT 'github' NOT NULL,
208
+ "installation_id" integer NOT NULL,
209
+ "owner" text NOT NULL,
210
+ "owner_type" text DEFAULT 'User' NOT NULL,
211
+ "provider_user_id" text,
212
+ "provider_owner_id" text,
213
+ "is_org" boolean DEFAULT false NOT NULL,
214
+ "created_at" timestamp DEFAULT now() NOT NULL,
215
+ "updated_at" timestamp DEFAULT now() NOT NULL
216
+ );
217
+ --> statement-breakpoint
218
+ CREATE TABLE "instance_settings" (
219
+ "id" text PRIMARY KEY DEFAULT 'default' NOT NULL,
220
+ "tunnel_provider" text,
221
+ "tunnel_token" text,
222
+ "auth_mode" text DEFAULT 'none' NOT NULL,
223
+ "default_build_mode" text DEFAULT 'auto' NOT NULL,
224
+ "default_rollback_window" integer DEFAULT 5 NOT NULL,
225
+ "created_at" timestamp DEFAULT now() NOT NULL,
226
+ "updated_at" timestamp DEFAULT now() NOT NULL
227
+ );
228
+ --> statement-breakpoint
229
+ CREATE TABLE "invitation" (
230
+ "id" text PRIMARY KEY NOT NULL,
231
+ "organization_id" text NOT NULL,
232
+ "email" text NOT NULL,
233
+ "role" text DEFAULT 'member' NOT NULL,
234
+ "status" text DEFAULT 'pending' NOT NULL,
235
+ "inviter_id" text NOT NULL,
236
+ "expires_at" timestamp NOT NULL,
237
+ "created_at" timestamp DEFAULT now() NOT NULL
238
+ );
239
+ --> statement-breakpoint
240
+ CREATE TABLE "invitation_pending_grant" (
241
+ "id" text PRIMARY KEY NOT NULL,
242
+ "invitation_id" text NOT NULL,
243
+ "resource_type" text NOT NULL,
244
+ "resource_id" text NOT NULL,
245
+ "permissions_json" text DEFAULT '[]' NOT NULL,
246
+ "created_at" timestamp DEFAULT now() NOT NULL
247
+ );
248
+ --> statement-breakpoint
249
+ CREATE TABLE "mail_servers" (
250
+ "server_id" text PRIMARY KEY NOT NULL,
251
+ "domain" text NOT NULL,
252
+ "installed_at" timestamp,
253
+ "created_at" timestamp DEFAULT now() NOT NULL,
254
+ "updated_at" timestamp DEFAULT now() NOT NULL
255
+ );
256
+ --> statement-breakpoint
257
+ CREATE TABLE "member" (
258
+ "id" text PRIMARY KEY NOT NULL,
259
+ "organization_id" text NOT NULL,
260
+ "user_id" text NOT NULL,
261
+ "role" text DEFAULT 'member' NOT NULL,
262
+ "created_at" timestamp DEFAULT now() NOT NULL
263
+ );
264
+ --> statement-breakpoint
265
+ CREATE TABLE "notification_channel" (
266
+ "id" text PRIMARY KEY NOT NULL,
267
+ "user_id" text NOT NULL,
268
+ "kind" text NOT NULL,
269
+ "label" text NOT NULL,
270
+ "config" jsonb DEFAULT '{}'::jsonb NOT NULL,
271
+ "verified" boolean DEFAULT false NOT NULL,
272
+ "enabled" boolean DEFAULT true NOT NULL,
273
+ "last_delivered_at" timestamp,
274
+ "created_at" timestamp DEFAULT now() NOT NULL,
275
+ "updated_at" timestamp DEFAULT now() NOT NULL
276
+ );
277
+ --> statement-breakpoint
278
+ CREATE TABLE "notification_default" (
279
+ "organization_id" text NOT NULL,
280
+ "category" text NOT NULL,
281
+ "default_enabled" boolean DEFAULT true NOT NULL,
282
+ "default_channel_kind" text DEFAULT 'email' NOT NULL,
283
+ "created_at" timestamp DEFAULT now() NOT NULL,
284
+ "updated_at" timestamp DEFAULT now() NOT NULL
285
+ );
286
+ --> statement-breakpoint
287
+ CREATE TABLE "notification_delivery" (
288
+ "id" text PRIMARY KEY NOT NULL,
289
+ "user_id" text NOT NULL,
290
+ "organization_id" text NOT NULL,
291
+ "audit_event_id" text,
292
+ "category" text NOT NULL,
293
+ "channel_id" text,
294
+ "channel_kind" text NOT NULL,
295
+ "status" text DEFAULT 'queued' NOT NULL,
296
+ "attempts" integer DEFAULT 0 NOT NULL,
297
+ "payload" jsonb DEFAULT '{}'::jsonb NOT NULL,
298
+ "last_error" text,
299
+ "created_at" timestamp DEFAULT now() NOT NULL,
300
+ "sent_at" timestamp,
301
+ "seen_at" timestamp
302
+ );
303
+ --> statement-breakpoint
304
+ CREATE TABLE "notification_subscription" (
305
+ "id" text PRIMARY KEY NOT NULL,
306
+ "user_id" text NOT NULL,
307
+ "organization_id" text NOT NULL,
308
+ "category" text NOT NULL,
309
+ "channel_id" text NOT NULL,
310
+ "enabled" boolean DEFAULT true NOT NULL,
311
+ "created_at" timestamp DEFAULT now() NOT NULL,
312
+ "updated_at" timestamp DEFAULT now() NOT NULL
313
+ );
314
+ --> statement-breakpoint
315
+ CREATE TABLE "organization" (
316
+ "id" text PRIMARY KEY NOT NULL,
317
+ "name" text NOT NULL,
318
+ "slug" text,
319
+ "logo" text,
320
+ "metadata" text,
321
+ "is_team" boolean DEFAULT false NOT NULL,
322
+ "created_at" timestamp DEFAULT now() NOT NULL,
323
+ CONSTRAINT "organization_slug_unique" UNIQUE("slug")
324
+ );
325
+ --> statement-breakpoint
326
+ CREATE TABLE "project" (
327
+ "id" text PRIMARY KEY NOT NULL,
328
+ "organization_id" text NOT NULL,
329
+ "app_id" text NOT NULL,
330
+ "name" text NOT NULL,
331
+ "slug" text NOT NULL,
332
+ "environment_name" text DEFAULT 'Production' NOT NULL,
333
+ "environment_slug" text DEFAULT 'production' NOT NULL,
334
+ "environment_type" text DEFAULT 'production' NOT NULL,
335
+ "local_path" text,
336
+ "git_provider" text DEFAULT 'github',
337
+ "git_owner" text,
338
+ "git_repo" text,
339
+ "git_branch" text DEFAULT 'main',
340
+ "git_url" text,
341
+ "installation_id" integer,
342
+ "clone_token_encrypted" text,
343
+ "clone_token_set_at" timestamp,
344
+ "framework" text DEFAULT 'unknown',
345
+ "package_manager" text DEFAULT 'npm',
346
+ "install_command" text,
347
+ "build_command" text,
348
+ "output_directory" text,
349
+ "production_paths" text,
350
+ "root_directory" text,
351
+ "start_command" text,
352
+ "build_image" text,
353
+ "production_mode" text DEFAULT 'host',
354
+ "port" integer DEFAULT 3000,
355
+ "has_server" boolean DEFAULT true NOT NULL,
356
+ "has_build" boolean DEFAULT true NOT NULL,
357
+ "workspace_install_command" text,
358
+ "resources" jsonb,
359
+ "build_resources" jsonb,
360
+ "sleep_mode" text DEFAULT 'auto_sleep',
361
+ "rollback_window" integer,
362
+ "cloud_archive_strategy" text DEFAULT 'inplace' NOT NULL,
363
+ "active_deployment_id" text,
364
+ "webhook_id" integer,
365
+ "webhook_domain" text,
366
+ "auto_deploy" boolean DEFAULT false NOT NULL,
367
+ "favicon" text,
368
+ "favicon_checked_at" timestamp,
369
+ "deleted_at" timestamp,
370
+ "created_at" timestamp DEFAULT now() NOT NULL,
371
+ "updated_at" timestamp DEFAULT now() NOT NULL
372
+ );
373
+ --> statement-breakpoint
374
+ CREATE TABLE "project_app" (
375
+ "id" text PRIMARY KEY NOT NULL,
376
+ "organization_id" text NOT NULL,
377
+ "name" text NOT NULL,
378
+ "slug" text NOT NULL,
379
+ "git_provider" text DEFAULT 'github',
380
+ "git_owner" text,
381
+ "git_repo" text,
382
+ "git_url" text,
383
+ "installation_id" integer,
384
+ "favicon" text,
385
+ "favicon_checked_at" timestamp,
386
+ "deleted_at" timestamp,
387
+ "created_at" timestamp DEFAULT now() NOT NULL,
388
+ "updated_at" timestamp DEFAULT now() NOT NULL
389
+ );
390
+ --> statement-breakpoint
391
+ CREATE TABLE "resource_grant" (
392
+ "id" text PRIMARY KEY NOT NULL,
393
+ "organization_id" text NOT NULL,
394
+ "user_id" text NOT NULL,
395
+ "resource_type" text NOT NULL,
396
+ "resource_id" text NOT NULL,
397
+ "permissions_json" text DEFAULT '[]' NOT NULL,
398
+ "granted_by_user_id" text,
399
+ "created_at" timestamp DEFAULT now() NOT NULL
400
+ );
401
+ --> statement-breakpoint
402
+ CREATE TABLE "server_analytics" (
403
+ "id" text PRIMARY KEY NOT NULL,
404
+ "server_id" text NOT NULL,
405
+ "domain" text NOT NULL,
406
+ "minute" integer NOT NULL,
407
+ "requests" integer DEFAULT 0 NOT NULL,
408
+ "unique_requests" integer DEFAULT 0 NOT NULL,
409
+ "bandwidth_in" integer DEFAULT 0 NOT NULL,
410
+ "bandwidth_out" integer DEFAULT 0 NOT NULL,
411
+ "response_time" real DEFAULT 0 NOT NULL,
412
+ "countries" jsonb,
413
+ "created_at" timestamp DEFAULT now() NOT NULL
414
+ );
415
+ --> statement-breakpoint
416
+ CREATE TABLE "server_analytics_geo" (
417
+ "id" text PRIMARY KEY NOT NULL,
418
+ "server_id" text NOT NULL,
419
+ "domain" text NOT NULL,
420
+ "day" text NOT NULL,
421
+ "countries" jsonb NOT NULL,
422
+ "created_at" timestamp DEFAULT now() NOT NULL
423
+ );
424
+ --> statement-breakpoint
425
+ CREATE TABLE "servers" (
426
+ "id" text PRIMARY KEY NOT NULL,
427
+ "organization_id" text,
428
+ "name" text,
429
+ "ssh_host" text NOT NULL,
430
+ "ssh_port" integer DEFAULT 22,
431
+ "ssh_user" text DEFAULT 'root',
432
+ "ssh_auth_method" text,
433
+ "ssh_password" text,
434
+ "ssh_key_path" text,
435
+ "ssh_key_passphrase" text,
436
+ "ssh_jump_host" text,
437
+ "ssh_args" text,
438
+ "created_at" timestamp DEFAULT now() NOT NULL,
439
+ "updated_at" timestamp DEFAULT now() NOT NULL
440
+ );
441
+ --> statement-breakpoint
442
+ CREATE TABLE "service" (
443
+ "id" text PRIMARY KEY NOT NULL,
444
+ "project_id" text NOT NULL,
445
+ "kind" text DEFAULT 'compose' NOT NULL,
446
+ "name" text NOT NULL,
447
+ "image" text,
448
+ "build" text,
449
+ "dockerfile" text,
450
+ "ports" jsonb DEFAULT '[]'::jsonb,
451
+ "depends_on" jsonb DEFAULT '[]'::jsonb,
452
+ "environment" jsonb DEFAULT '{}'::jsonb,
453
+ "volumes" jsonb DEFAULT '[]'::jsonb,
454
+ "command" text,
455
+ "restart" text DEFAULT 'unless-stopped',
456
+ "exposed" boolean DEFAULT false NOT NULL,
457
+ "exposed_port" text,
458
+ "domain" text,
459
+ "custom_domain" text,
460
+ "domain_type" text DEFAULT 'free',
461
+ "root_directory" text,
462
+ "install_command" text,
463
+ "build_command" text,
464
+ "start_command" text,
465
+ "output_directory" text,
466
+ "framework" text,
467
+ "package_manager" text,
468
+ "build_image" text,
469
+ "enabled" boolean DEFAULT true NOT NULL,
470
+ "sort_order" integer DEFAULT 0 NOT NULL,
471
+ "created_at" timestamp DEFAULT now() NOT NULL,
472
+ "updated_at" timestamp DEFAULT now() NOT NULL
473
+ );
474
+ --> statement-breakpoint
475
+ CREATE TABLE "service_deployment" (
476
+ "id" text PRIMARY KEY NOT NULL,
477
+ "deployment_id" text NOT NULL,
478
+ "service_id" text NOT NULL,
479
+ "container_id" text,
480
+ "status" text DEFAULT 'pending' NOT NULL,
481
+ "image_ref" text,
482
+ "host_port" integer,
483
+ "ip" text,
484
+ "created_at" timestamp DEFAULT now() NOT NULL,
485
+ "updated_at" timestamp DEFAULT now() NOT NULL
486
+ );
487
+ --> statement-breakpoint
488
+ CREATE TABLE "service_terminal_sessions" (
489
+ "id" text PRIMARY KEY NOT NULL,
490
+ "user_id" text NOT NULL,
491
+ "service_id" text NOT NULL,
492
+ "started_at" timestamp DEFAULT now() NOT NULL,
493
+ "ended_at" timestamp,
494
+ "exit_code" integer,
495
+ "exit_reason" text,
496
+ "client_ip" text,
497
+ "user_agent" text
498
+ );
499
+ --> statement-breakpoint
500
+ CREATE TABLE "session" (
501
+ "id" text PRIMARY KEY NOT NULL,
502
+ "expires_at" timestamp NOT NULL,
503
+ "token" text NOT NULL,
504
+ "created_at" timestamp DEFAULT now() NOT NULL,
505
+ "updated_at" timestamp DEFAULT now() NOT NULL,
506
+ "ip_address" text,
507
+ "user_agent" text,
508
+ "user_id" text NOT NULL,
509
+ "active_organization_id" text,
510
+ CONSTRAINT "session_token_unique" UNIQUE("token")
511
+ );
512
+ --> statement-breakpoint
513
+ CREATE TABLE "terminal_sessions" (
514
+ "id" text PRIMARY KEY NOT NULL,
515
+ "user_id" text NOT NULL,
516
+ "server_id" text NOT NULL,
517
+ "started_at" timestamp DEFAULT now() NOT NULL,
518
+ "ended_at" timestamp,
519
+ "exit_code" integer,
520
+ "exit_reason" text,
521
+ "client_ip" text,
522
+ "user_agent" text
523
+ );
524
+ --> statement-breakpoint
525
+ CREATE TABLE "user" (
526
+ "id" text PRIMARY KEY NOT NULL,
527
+ "name" text NOT NULL,
528
+ "email" text NOT NULL,
529
+ "email_verified" boolean DEFAULT false NOT NULL,
530
+ "image" text,
531
+ "role" text DEFAULT 'user' NOT NULL,
532
+ "auto_provisioned" boolean DEFAULT false NOT NULL,
533
+ "created_at" timestamp DEFAULT now() NOT NULL,
534
+ "updated_at" timestamp DEFAULT now() NOT NULL,
535
+ CONSTRAINT "user_email_unique" UNIQUE("email")
536
+ );
537
+ --> statement-breakpoint
538
+ CREATE TABLE "user_settings" (
539
+ "id" text PRIMARY KEY NOT NULL,
540
+ "user_id" text NOT NULL,
541
+ "build_mode" text DEFAULT 'auto' NOT NULL,
542
+ "cloud_session_token" text,
543
+ "default_deploy_target" text,
544
+ "default_server_id" text,
545
+ "clone_token_encrypted" text,
546
+ "clone_token_set_at" timestamp,
547
+ "clone_token_as_default" boolean DEFAULT false NOT NULL,
548
+ "clone_strategy_preference" text DEFAULT 'prompt' NOT NULL,
549
+ "github_cli_disabled" boolean DEFAULT false NOT NULL,
550
+ "created_at" timestamp DEFAULT now() NOT NULL,
551
+ "updated_at" timestamp DEFAULT now() NOT NULL,
552
+ CONSTRAINT "user_settings_user_id_unique" UNIQUE("user_id")
553
+ );
554
+ --> statement-breakpoint
555
+ CREATE TABLE "verification" (
556
+ "id" text PRIMARY KEY NOT NULL,
557
+ "identifier" text NOT NULL,
558
+ "value" text NOT NULL,
559
+ "expires_at" timestamp NOT NULL,
560
+ "created_at" timestamp DEFAULT now(),
561
+ "updated_at" timestamp DEFAULT now()
562
+ );
563
+ --> statement-breakpoint
564
+ ALTER TABLE "account" ADD CONSTRAINT "account_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
565
+ ALTER TABLE "audit_event" ADD CONSTRAINT "audit_event_organization_id_organization_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
566
+ ALTER TABLE "audit_event" ADD CONSTRAINT "audit_event_actor_user_id_user_id_fk" FOREIGN KEY ("actor_user_id") REFERENCES "public"."user"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
567
+ ALTER TABLE "backup_destination" ADD CONSTRAINT "backup_destination_organization_id_organization_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
568
+ ALTER TABLE "backup_destination" ADD CONSTRAINT "backup_destination_server_id_servers_id_fk" FOREIGN KEY ("server_id") REFERENCES "public"."servers"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
569
+ ALTER TABLE "backup_policy" ADD CONSTRAINT "backup_policy_project_id_project_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."project"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
570
+ ALTER TABLE "backup_policy" ADD CONSTRAINT "backup_policy_service_id_service_id_fk" FOREIGN KEY ("service_id") REFERENCES "public"."service"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
571
+ ALTER TABLE "backup_policy" ADD CONSTRAINT "backup_policy_destination_id_backup_destination_id_fk" FOREIGN KEY ("destination_id") REFERENCES "public"."backup_destination"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
572
+ ALTER TABLE "backup_policy" ADD CONSTRAINT "backup_policy_created_by_user_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
573
+ ALTER TABLE "backup_restore" ADD CONSTRAINT "backup_restore_run_id_backup_run_id_fk" FOREIGN KEY ("run_id") REFERENCES "public"."backup_run"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
574
+ ALTER TABLE "backup_restore" ADD CONSTRAINT "backup_restore_destination_id_backup_destination_id_fk" FOREIGN KEY ("destination_id") REFERENCES "public"."backup_destination"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
575
+ ALTER TABLE "backup_restore" ADD CONSTRAINT "backup_restore_project_id_project_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."project"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
576
+ ALTER TABLE "backup_restore" ADD CONSTRAINT "backup_restore_service_id_service_id_fk" FOREIGN KEY ("service_id") REFERENCES "public"."service"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
577
+ ALTER TABLE "backup_restore" ADD CONSTRAINT "backup_restore_organization_id_organization_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
578
+ ALTER TABLE "backup_restore" ADD CONSTRAINT "backup_restore_fork_service_id_service_id_fk" FOREIGN KEY ("fork_service_id") REFERENCES "public"."service"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
579
+ ALTER TABLE "backup_run" ADD CONSTRAINT "backup_run_policy_id_backup_policy_id_fk" FOREIGN KEY ("policy_id") REFERENCES "public"."backup_policy"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
580
+ ALTER TABLE "backup_run" ADD CONSTRAINT "backup_run_destination_id_backup_destination_id_fk" FOREIGN KEY ("destination_id") REFERENCES "public"."backup_destination"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
581
+ ALTER TABLE "backup_run" ADD CONSTRAINT "backup_run_project_id_project_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."project"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
582
+ ALTER TABLE "backup_run" ADD CONSTRAINT "backup_run_service_id_service_id_fk" FOREIGN KEY ("service_id") REFERENCES "public"."service"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
583
+ ALTER TABLE "backup_run" ADD CONSTRAINT "backup_run_organization_id_organization_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
584
+ ALTER TABLE "backup_run" ADD CONSTRAINT "backup_run_triggered_by_user_id_user_id_fk" FOREIGN KEY ("triggered_by_user_id") REFERENCES "public"."user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
585
+ ALTER TABLE "build_session" ADD CONSTRAINT "build_session_deployment_id_deployment_id_fk" FOREIGN KEY ("deployment_id") REFERENCES "public"."deployment"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
586
+ ALTER TABLE "build_session" ADD CONSTRAINT "build_session_project_id_project_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."project"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
587
+ ALTER TABLE "deployment" ADD CONSTRAINT "deployment_project_id_project_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."project"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
588
+ ALTER TABLE "deployment" ADD CONSTRAINT "deployment_organization_id_organization_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
589
+ ALTER TABLE "domain" ADD CONSTRAINT "domain_project_id_project_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."project"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
590
+ ALTER TABLE "env_var" ADD CONSTRAINT "env_var_project_id_project_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."project"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
591
+ ALTER TABLE "git_installation" ADD CONSTRAINT "git_installation_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
592
+ ALTER TABLE "git_installation" ADD CONSTRAINT "git_installation_organization_id_organization_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
593
+ ALTER TABLE "invitation" ADD CONSTRAINT "invitation_organization_id_organization_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
594
+ ALTER TABLE "invitation" ADD CONSTRAINT "invitation_inviter_id_user_id_fk" FOREIGN KEY ("inviter_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
595
+ ALTER TABLE "invitation_pending_grant" ADD CONSTRAINT "invitation_pending_grant_invitation_id_invitation_id_fk" FOREIGN KEY ("invitation_id") REFERENCES "public"."invitation"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
596
+ ALTER TABLE "mail_servers" ADD CONSTRAINT "mail_servers_server_id_servers_id_fk" FOREIGN KEY ("server_id") REFERENCES "public"."servers"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
597
+ ALTER TABLE "member" ADD CONSTRAINT "member_organization_id_organization_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
598
+ ALTER TABLE "member" ADD CONSTRAINT "member_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
599
+ ALTER TABLE "notification_channel" ADD CONSTRAINT "notification_channel_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
600
+ ALTER TABLE "notification_default" ADD CONSTRAINT "notification_default_organization_id_organization_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
601
+ ALTER TABLE "notification_delivery" ADD CONSTRAINT "notification_delivery_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
602
+ ALTER TABLE "notification_delivery" ADD CONSTRAINT "notification_delivery_organization_id_organization_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
603
+ ALTER TABLE "notification_delivery" ADD CONSTRAINT "notification_delivery_audit_event_id_audit_event_id_fk" FOREIGN KEY ("audit_event_id") REFERENCES "public"."audit_event"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
604
+ ALTER TABLE "notification_delivery" ADD CONSTRAINT "notification_delivery_channel_id_notification_channel_id_fk" FOREIGN KEY ("channel_id") REFERENCES "public"."notification_channel"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
605
+ ALTER TABLE "notification_subscription" ADD CONSTRAINT "notification_subscription_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
606
+ ALTER TABLE "notification_subscription" ADD CONSTRAINT "notification_subscription_organization_id_organization_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
607
+ ALTER TABLE "notification_subscription" ADD CONSTRAINT "notification_subscription_channel_id_notification_channel_id_fk" FOREIGN KEY ("channel_id") REFERENCES "public"."notification_channel"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
608
+ ALTER TABLE "project" ADD CONSTRAINT "project_organization_id_organization_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
609
+ ALTER TABLE "project" ADD CONSTRAINT "project_app_id_project_app_id_fk" FOREIGN KEY ("app_id") REFERENCES "public"."project_app"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
610
+ ALTER TABLE "project_app" ADD CONSTRAINT "project_app_organization_id_organization_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
611
+ ALTER TABLE "resource_grant" ADD CONSTRAINT "resource_grant_organization_id_organization_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
612
+ ALTER TABLE "resource_grant" ADD CONSTRAINT "resource_grant_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
613
+ ALTER TABLE "resource_grant" ADD CONSTRAINT "resource_grant_granted_by_user_id_user_id_fk" FOREIGN KEY ("granted_by_user_id") REFERENCES "public"."user"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
614
+ ALTER TABLE "server_analytics" ADD CONSTRAINT "server_analytics_server_id_servers_id_fk" FOREIGN KEY ("server_id") REFERENCES "public"."servers"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
615
+ ALTER TABLE "server_analytics_geo" ADD CONSTRAINT "server_analytics_geo_server_id_servers_id_fk" FOREIGN KEY ("server_id") REFERENCES "public"."servers"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
616
+ ALTER TABLE "servers" ADD CONSTRAINT "servers_organization_id_organization_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organization"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
617
+ ALTER TABLE "service" ADD CONSTRAINT "service_project_id_project_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."project"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
618
+ ALTER TABLE "service_deployment" ADD CONSTRAINT "service_deployment_deployment_id_deployment_id_fk" FOREIGN KEY ("deployment_id") REFERENCES "public"."deployment"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
619
+ ALTER TABLE "service_deployment" ADD CONSTRAINT "service_deployment_service_id_service_id_fk" FOREIGN KEY ("service_id") REFERENCES "public"."service"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
620
+ ALTER TABLE "service_terminal_sessions" ADD CONSTRAINT "service_terminal_sessions_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
621
+ ALTER TABLE "service_terminal_sessions" ADD CONSTRAINT "service_terminal_sessions_service_id_service_id_fk" FOREIGN KEY ("service_id") REFERENCES "public"."service"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
622
+ ALTER TABLE "session" ADD CONSTRAINT "session_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
623
+ ALTER TABLE "terminal_sessions" ADD CONSTRAINT "terminal_sessions_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
624
+ ALTER TABLE "terminal_sessions" ADD CONSTRAINT "terminal_sessions_server_id_servers_id_fk" FOREIGN KEY ("server_id") REFERENCES "public"."servers"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
625
+ ALTER TABLE "user_settings" ADD CONSTRAINT "user_settings_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
626
+ CREATE INDEX "audit_event_org_created_idx" ON "audit_event" USING btree ("organization_id","created_at");--> statement-breakpoint
627
+ CREATE INDEX "audit_event_org_type_idx" ON "audit_event" USING btree ("organization_id","event_type");--> statement-breakpoint
628
+ CREATE INDEX "audit_event_org_actor_idx" ON "audit_event" USING btree ("organization_id","actor_user_id");--> statement-breakpoint
629
+ CREATE INDEX "audit_event_resource_idx" ON "audit_event" USING btree ("resource_type","resource_id");--> statement-breakpoint
630
+ CREATE UNIQUE INDEX "uq_backup_destination_org_name_active" ON "backup_destination" USING btree ("organization_id","name") WHERE "backup_destination"."deleted_at" IS NULL;--> statement-breakpoint
631
+ CREATE INDEX "idx_backup_destination_org" ON "backup_destination" USING btree ("organization_id");--> statement-breakpoint
632
+ CREATE UNIQUE INDEX "uq_backup_policy_project_service" ON "backup_policy" USING btree ("project_id","service_id") WHERE "backup_policy"."deleted_at" IS NULL;--> statement-breakpoint
633
+ CREATE UNIQUE INDEX "uq_backup_policy_webhook_token" ON "backup_policy" USING btree ("webhook_token") WHERE "backup_policy"."webhook_token" IS NOT NULL;--> statement-breakpoint
634
+ CREATE INDEX "idx_backup_policy_project" ON "backup_policy" USING btree ("project_id");--> statement-breakpoint
635
+ CREATE INDEX "idx_backup_policy_destination" ON "backup_policy" USING btree ("destination_id");--> statement-breakpoint
636
+ CREATE INDEX "idx_backup_restore_org_started" ON "backup_restore" USING btree ("organization_id","started_at");--> statement-breakpoint
637
+ CREATE INDEX "idx_backup_restore_run" ON "backup_restore" USING btree ("run_id");--> statement-breakpoint
638
+ CREATE INDEX "idx_backup_run_org_started" ON "backup_run" USING btree ("organization_id","started_at");--> statement-breakpoint
639
+ CREATE INDEX "idx_backup_run_destination_started" ON "backup_run" USING btree ("destination_id","started_at");--> statement-breakpoint
640
+ CREATE INDEX "idx_backup_run_project_started" ON "backup_run" USING btree ("project_id","started_at");--> statement-breakpoint
641
+ CREATE INDEX "idx_backup_run_in_flight" ON "backup_run" USING btree ("status") WHERE "backup_run"."status" IN ('queued','preparing','snapshotting','uploading','verifying');--> statement-breakpoint
642
+ CREATE INDEX "cloud_handoff_code_expires_idx" ON "cloud_handoff_code" USING btree ("expires_at");--> statement-breakpoint
643
+ CREATE INDEX "invitation_org_idx" ON "invitation" USING btree ("organization_id");--> statement-breakpoint
644
+ CREATE INDEX "invitation_email_idx" ON "invitation" USING btree ("email");--> statement-breakpoint
645
+ CREATE INDEX "invitation_pending_grant_invitation_idx" ON "invitation_pending_grant" USING btree ("invitation_id");--> statement-breakpoint
646
+ CREATE UNIQUE INDEX "member_org_user_unique" ON "member" USING btree ("organization_id","user_id");--> statement-breakpoint
647
+ CREATE INDEX "member_org_idx" ON "member" USING btree ("organization_id");--> statement-breakpoint
648
+ CREATE INDEX "member_user_idx" ON "member" USING btree ("user_id");--> statement-breakpoint
649
+ CREATE INDEX "idx_notification_channel_user" ON "notification_channel" USING btree ("user_id");--> statement-breakpoint
650
+ CREATE UNIQUE INDEX "uq_notification_default_org_category" ON "notification_default" USING btree ("organization_id","category");--> statement-breakpoint
651
+ CREATE INDEX "idx_notification_delivery_user_created" ON "notification_delivery" USING btree ("user_id","created_at");--> statement-breakpoint
652
+ CREATE INDEX "idx_notification_delivery_queued" ON "notification_delivery" USING btree ("status","created_at");--> statement-breakpoint
653
+ CREATE INDEX "idx_notification_delivery_org_created" ON "notification_delivery" USING btree ("organization_id","created_at");--> statement-breakpoint
654
+ CREATE UNIQUE INDEX "uq_notification_subscription_unique" ON "notification_subscription" USING btree ("user_id","organization_id","category","channel_id");--> statement-breakpoint
655
+ CREATE INDEX "idx_notification_subscription_dispatch" ON "notification_subscription" USING btree ("organization_id","category","enabled");--> statement-breakpoint
656
+ CREATE UNIQUE INDEX "uq_project_app_environment_slug_active" ON "project" USING btree ("app_id","environment_slug") WHERE "project"."deleted_at" IS NULL;--> statement-breakpoint
657
+ CREATE UNIQUE INDEX "resource_grant_unique" ON "resource_grant" USING btree ("organization_id","user_id","resource_type","resource_id");--> statement-breakpoint
658
+ CREATE INDEX "resource_grant_member_idx" ON "resource_grant" USING btree ("organization_id","user_id");--> statement-breakpoint
659
+ CREATE INDEX "resource_grant_resource_idx" ON "resource_grant" USING btree ("organization_id","resource_type","resource_id");--> statement-breakpoint
660
+ CREATE UNIQUE INDEX "uq_analytics_server_domain_minute" ON "server_analytics" USING btree ("server_id","domain","minute");--> statement-breakpoint
661
+ CREATE INDEX "idx_analytics_domain_minute" ON "server_analytics" USING btree ("domain","minute");--> statement-breakpoint
662
+ CREATE UNIQUE INDEX "uq_analytics_geo_server_domain_day" ON "server_analytics_geo" USING btree ("server_id","domain","day");--> statement-breakpoint
663
+ CREATE INDEX "service_terminal_sessions_user_idx" ON "service_terminal_sessions" USING btree ("user_id","started_at");--> statement-breakpoint
664
+ CREATE INDEX "service_terminal_sessions_service_idx" ON "service_terminal_sessions" USING btree ("service_id","started_at");--> statement-breakpoint
665
+ CREATE INDEX "terminal_sessions_user_idx" ON "terminal_sessions" USING btree ("user_id","started_at");--> statement-breakpoint
666
+ CREATE INDEX "terminal_sessions_server_idx" ON "terminal_sessions" USING btree ("server_id","started_at");