20230503225831.sql 44 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154
  1. -- Create "deployments" table
  2. CREATE TABLE "public"."deployments" (
  3. "id" bigserial NOT NULL,
  4. "created_at" timestamptz NULL,
  5. "updated_at" timestamptz NULL,
  6. "deleted_at" timestamptz NULL,
  7. "environment_id" bigint NULL,
  8. "namespace" text NULL,
  9. "status" text NULL,
  10. "subdomain" text NULL,
  11. "pull_request_id" bigint NULL,
  12. "gh_deployment_id" bigint NULL,
  13. "ghpr_comment_id" bigint NULL,
  14. "pr_name" text NULL,
  15. "repo_name" text NULL,
  16. "repo_owner" text NULL,
  17. "commit_sha" text NULL,
  18. "pr_branch_from" text NULL,
  19. "pr_branch_into" text NULL,
  20. "last_errors" text NULL,
  21. PRIMARY KEY ("id")
  22. );
  23. -- Create index "idx_deployments_deleted_at" to table: "deployments"
  24. CREATE INDEX "idx_deployments_deleted_at" ON "public"."deployments" ("deleted_at");
  25. -- Create "token_caches" table
  26. CREATE TABLE "public"."token_caches" (
  27. "id" bigserial NOT NULL,
  28. "created_at" timestamptz NULL,
  29. "updated_at" timestamptz NULL,
  30. "deleted_at" timestamptz NULL,
  31. "expiry" timestamptz NULL,
  32. "token" bytea NULL,
  33. PRIMARY KEY ("id")
  34. );
  35. -- Create index "idx_token_caches_deleted_at" to table: "token_caches"
  36. CREATE INDEX "idx_token_caches_deleted_at" ON "public"."token_caches" ("deleted_at");
  37. -- Create "api_tokens" table
  38. CREATE TABLE "public"."api_tokens" (
  39. "id" bigserial NOT NULL,
  40. "created_at" timestamptz NULL,
  41. "updated_at" timestamptz NULL,
  42. "deleted_at" timestamptz NULL,
  43. "unique_id" text NULL,
  44. "project_id" bigint NULL,
  45. "created_by_user_id" bigint NULL,
  46. "expiry" timestamptz NULL,
  47. "revoked" boolean NULL,
  48. "policy_uid" text NULL,
  49. "policy_name" text NULL,
  50. "name" text NULL,
  51. "secret_key" bytea NULL,
  52. PRIMARY KEY ("id")
  53. );
  54. -- Create index "api_tokens_unique_id_key" to table: "api_tokens"
  55. CREATE UNIQUE INDEX "api_tokens_unique_id_key" ON "public"."api_tokens" ("unique_id");
  56. -- Create index "idx_api_tokens_deleted_at" to table: "api_tokens"
  57. CREATE INDEX "idx_api_tokens_deleted_at" ON "public"."api_tokens" ("deleted_at");
  58. -- Create "auth_codes" table
  59. CREATE TABLE "public"."auth_codes" (
  60. "id" bigserial NOT NULL,
  61. "created_at" timestamptz NULL,
  62. "updated_at" timestamptz NULL,
  63. "deleted_at" timestamptz NULL,
  64. "token" text NULL,
  65. "authorization_code" text NULL,
  66. "expiry" timestamptz NULL,
  67. PRIMARY KEY ("id")
  68. );
  69. -- Create index "auth_codes_authorization_code_key" to table: "auth_codes"
  70. CREATE UNIQUE INDEX "auth_codes_authorization_code_key" ON "public"."auth_codes" ("authorization_code");
  71. -- Create index "auth_codes_token_key" to table: "auth_codes"
  72. CREATE UNIQUE INDEX "auth_codes_token_key" ON "public"."auth_codes" ("token");
  73. -- Create index "idx_auth_codes_deleted_at" to table: "auth_codes"
  74. CREATE INDEX "idx_auth_codes_deleted_at" ON "public"."auth_codes" ("deleted_at");
  75. -- Create "policies" table
  76. CREATE TABLE "public"."policies" (
  77. "id" bigserial NOT NULL,
  78. "created_at" timestamptz NULL,
  79. "updated_at" timestamptz NULL,
  80. "deleted_at" timestamptz NULL,
  81. "unique_id" text NULL,
  82. "project_id" bigint NULL,
  83. "created_by_user_id" bigint NULL,
  84. "name" text NULL,
  85. "policy_bytes" bytea NULL,
  86. PRIMARY KEY ("id")
  87. );
  88. -- Create index "idx_policies_deleted_at" to table: "policies"
  89. CREATE INDEX "idx_policies_deleted_at" ON "public"."policies" ("deleted_at");
  90. -- Create index "policies_unique_id_key" to table: "policies"
  91. CREATE UNIQUE INDEX "policies_unique_id_key" ON "public"."policies" ("unique_id");
  92. -- Create "porter_apps" table
  93. CREATE TABLE "public"."porter_apps" (
  94. "id" bigserial NOT NULL,
  95. "created_at" timestamptz NULL,
  96. "updated_at" timestamptz NULL,
  97. "deleted_at" timestamptz NULL,
  98. "project_id" bigint NULL,
  99. "cluster_id" bigint NULL,
  100. "name" text NULL,
  101. "image_repo_uri" text NULL,
  102. "git_repo_id" bigint NULL,
  103. "repo_name" text NULL,
  104. "git_branch" text NULL,
  105. "build_context" text NULL,
  106. "builder" text NULL,
  107. "buildpacks" text NULL,
  108. "dockerfile" text NULL,
  109. "pull_request_url" text NULL,
  110. PRIMARY KEY ("id")
  111. );
  112. -- Create index "idx_porter_apps_deleted_at" to table: "porter_apps"
  113. CREATE INDEX "idx_porter_apps_deleted_at" ON "public"."porter_apps" ("deleted_at");
  114. -- Create "user_billings" table
  115. CREATE TABLE "public"."user_billings" (
  116. "id" bigserial NOT NULL,
  117. "created_at" timestamptz NULL,
  118. "updated_at" timestamptz NULL,
  119. "deleted_at" timestamptz NULL,
  120. "project_id" bigint NULL,
  121. "user_id" bigint NULL,
  122. "teammate_id" text NULL,
  123. "token" bytea NULL,
  124. PRIMARY KEY ("id")
  125. );
  126. -- Create index "idx_user_billings_deleted_at" to table: "user_billings"
  127. CREATE INDEX "idx_user_billings_deleted_at" ON "public"."user_billings" ("deleted_at");
  128. -- Create "dns_records" table
  129. CREATE TABLE "public"."dns_records" (
  130. "id" bigserial NOT NULL,
  131. "created_at" timestamptz NULL,
  132. "updated_at" timestamptz NULL,
  133. "deleted_at" timestamptz NULL,
  134. "subdomain_prefix" text NULL,
  135. "root_domain" text NULL,
  136. "endpoint" text NULL,
  137. "hostname" text NULL,
  138. "cluster_id" bigint NULL,
  139. PRIMARY KEY ("id")
  140. );
  141. -- Create index "dns_records_subdomain_prefix_key" to table: "dns_records"
  142. CREATE UNIQUE INDEX "dns_records_subdomain_prefix_key" ON "public"."dns_records" ("subdomain_prefix");
  143. -- Create index "idx_dns_records_deleted_at" to table: "dns_records"
  144. CREATE INDEX "idx_dns_records_deleted_at" ON "public"."dns_records" ("deleted_at");
  145. -- Create "build_configs" table
  146. CREATE TABLE "public"."build_configs" (
  147. "id" bigserial NOT NULL,
  148. "created_at" timestamptz NULL,
  149. "updated_at" timestamptz NULL,
  150. "deleted_at" timestamptz NULL,
  151. "name" text NULL,
  152. "builder" text NULL,
  153. "buildpacks" text NULL,
  154. "config" bytea NULL,
  155. PRIMARY KEY ("id")
  156. );
  157. -- Create index "idx_build_configs_deleted_at" to table: "build_configs"
  158. CREATE INDEX "idx_build_configs_deleted_at" ON "public"."build_configs" ("deleted_at");
  159. -- Create "environments" table
  160. CREATE TABLE "public"."environments" (
  161. "id" bigserial NOT NULL,
  162. "created_at" timestamptz NULL,
  163. "updated_at" timestamptz NULL,
  164. "deleted_at" timestamptz NULL,
  165. "project_id" bigint NULL,
  166. "cluster_id" bigint NULL,
  167. "git_installation_id" bigint NULL,
  168. "git_repo_owner" text NULL,
  169. "git_repo_name" text NULL,
  170. "git_repo_branches" text NULL,
  171. "name" text NULL,
  172. "mode" text NULL,
  173. "new_comments_disabled" boolean NULL,
  174. "namespace_labels" bytea NULL,
  175. "namespace_annotations" bytea NULL,
  176. "git_deploy_branches" text NULL,
  177. "webhook_id" text NULL,
  178. "github_webhook_id" bigint NULL,
  179. PRIMARY KEY ("id")
  180. );
  181. -- Create index "environments_webhook_id_key" to table: "environments"
  182. CREATE UNIQUE INDEX "environments_webhook_id_key" ON "public"."environments" ("webhook_id");
  183. -- Create index "idx_environments_deleted_at" to table: "environments"
  184. CREATE INDEX "idx_environments_deleted_at" ON "public"."environments" ("deleted_at");
  185. -- Create "project_billings" table
  186. CREATE TABLE "public"."project_billings" (
  187. "id" bigserial NOT NULL,
  188. "created_at" timestamptz NULL,
  189. "updated_at" timestamptz NULL,
  190. "deleted_at" timestamptz NULL,
  191. "project_id" bigint NULL,
  192. "billing_team_id" text NULL,
  193. PRIMARY KEY ("id")
  194. );
  195. -- Create index "idx_project_billings_deleted_at" to table: "project_billings"
  196. CREATE INDEX "idx_project_billings_deleted_at" ON "public"."project_billings" ("deleted_at");
  197. -- Create "cluster_token_caches" table
  198. CREATE TABLE "public"."cluster_token_caches" (
  199. "id" bigserial NOT NULL,
  200. "created_at" timestamptz NULL,
  201. "updated_at" timestamptz NULL,
  202. "deleted_at" timestamptz NULL,
  203. "expiry" timestamptz NULL,
  204. "token" bytea NULL,
  205. "cluster_id" bigint NULL,
  206. PRIMARY KEY ("id")
  207. );
  208. -- Create index "idx_cluster_token_caches_deleted_at" to table: "cluster_token_caches"
  209. CREATE INDEX "idx_cluster_token_caches_deleted_at" ON "public"."cluster_token_caches" ("deleted_at");
  210. -- Create "slack_integrations" table
  211. CREATE TABLE "public"."slack_integrations" (
  212. "id" bigserial NOT NULL,
  213. "created_at" timestamptz NULL,
  214. "updated_at" timestamptz NULL,
  215. "deleted_at" timestamptz NULL,
  216. "client_id" bytea NULL,
  217. "access_token" bytea NULL,
  218. "refresh_token" bytea NULL,
  219. "expiry" timestamptz NULL,
  220. "client" text NULL,
  221. "user_id" bigint NULL,
  222. "project_id" bigint NULL,
  223. "team_id" text NULL,
  224. "team_name" text NULL,
  225. "team_icon_url" text NULL,
  226. "channel" text NULL,
  227. "channel_id" text NULL,
  228. "configuration_url" text NULL,
  229. "webhook" bytea NULL,
  230. PRIMARY KEY ("id")
  231. );
  232. -- Create index "idx_slack_integrations_deleted_at" to table: "slack_integrations"
  233. CREATE INDEX "idx_slack_integrations_deleted_at" ON "public"."slack_integrations" ("deleted_at");
  234. -- Create "credentials_exchange_tokens" table
  235. CREATE TABLE "public"."credentials_exchange_tokens" (
  236. "id" bigserial NOT NULL,
  237. "created_at" timestamptz NULL,
  238. "updated_at" timestamptz NULL,
  239. "deleted_at" timestamptz NULL,
  240. "project_id" bigint NULL,
  241. "token" bytea NULL,
  242. "expiry" timestamptz NULL,
  243. "do_credential_id" bigint NULL,
  244. "aws_credential_id" bigint NULL,
  245. "gcp_credential_id" bigint NULL,
  246. "azure_credential_id" bigint NULL,
  247. PRIMARY KEY ("id")
  248. );
  249. -- Create index "idx_credentials_exchange_tokens_deleted_at" to table: "credentials_exchange_tokens"
  250. CREATE INDEX "idx_credentials_exchange_tokens_deleted_at" ON "public"."credentials_exchange_tokens" ("deleted_at");
  251. -- Create "sessions" table
  252. CREATE TABLE "public"."sessions" (
  253. "id" bigserial NOT NULL,
  254. "created_at" timestamptz NULL,
  255. "updated_at" timestamptz NULL,
  256. "deleted_at" timestamptz NULL,
  257. "key" text NULL,
  258. "data" bytea NULL,
  259. "expires_at" timestamptz NULL,
  260. PRIMARY KEY ("id")
  261. );
  262. -- Create index "idx_sessions_deleted_at" to table: "sessions"
  263. CREATE INDEX "idx_sessions_deleted_at" ON "public"."sessions" ("deleted_at");
  264. -- Create index "sessions_key_key" to table: "sessions"
  265. CREATE UNIQUE INDEX "sessions_key_key" ON "public"."sessions" ("key");
  266. -- Create "db_migrations" table
  267. CREATE TABLE "public"."db_migrations" (
  268. "id" bigserial NOT NULL,
  269. "created_at" timestamptz NULL,
  270. "updated_at" timestamptz NULL,
  271. "deleted_at" timestamptz NULL,
  272. "version" bigint NULL,
  273. PRIMARY KEY ("id")
  274. );
  275. -- Create index "idx_db_migrations_deleted_at" to table: "db_migrations"
  276. CREATE INDEX "idx_db_migrations_deleted_at" ON "public"."db_migrations" ("deleted_at");
  277. -- Create "users" table
  278. CREATE TABLE "public"."users" (
  279. "id" bigserial NOT NULL,
  280. "created_at" timestamptz NULL,
  281. "updated_at" timestamptz NULL,
  282. "deleted_at" timestamptz NULL,
  283. "email" text NULL,
  284. "password" text NULL,
  285. "email_verified" boolean NULL,
  286. "first_name" text NULL,
  287. "last_name" text NULL,
  288. "company_name" text NULL,
  289. "github_app_integration_id" bigint NULL,
  290. "github_user_id" bigint NULL,
  291. "google_user_id" text NULL,
  292. PRIMARY KEY ("id")
  293. );
  294. -- Create index "idx_users_deleted_at" to table: "users"
  295. CREATE INDEX "idx_users_deleted_at" ON "public"."users" ("deleted_at");
  296. -- Create index "users_email_key" to table: "users"
  297. CREATE UNIQUE INDEX "users_email_key" ON "public"."users" ("email");
  298. -- Create "api_contract_revisions" table
  299. CREATE TABLE "public"."api_contract_revisions" (
  300. "id" uuid NOT NULL,
  301. "created_at" timestamptz NULL,
  302. "updated_at" timestamptz NULL,
  303. "deleted_at" timestamptz NULL,
  304. "base64_contract" text NULL,
  305. "cluster_id" bigint NULL,
  306. "project_id" bigint NULL,
  307. "condition" text NULL,
  308. "condition_metadata" jsonb NULL,
  309. PRIMARY KEY ("id")
  310. );
  311. -- Create index "idx_api_contract_revisions_deleted_at" to table: "api_contract_revisions"
  312. CREATE INDEX "idx_api_contract_revisions_deleted_at" ON "public"."api_contract_revisions" ("deleted_at");
  313. -- Create "onboardings" table
  314. CREATE TABLE "public"."onboardings" (
  315. "id" bigserial NOT NULL,
  316. "created_at" timestamptz NULL,
  317. "updated_at" timestamptz NULL,
  318. "deleted_at" timestamptz NULL,
  319. "project_id" bigint NULL,
  320. "current_step" text NULL,
  321. "connected_source" text NULL,
  322. "skip_registry_connection" boolean NULL,
  323. "skip_resource_provision" boolean NULL,
  324. "registry_connection_id" bigint NULL,
  325. "registry_connection_credential_id" bigint NULL,
  326. "registry_connection_provider" text NULL,
  327. "registry_infra_id" bigint NULL,
  328. "registry_infra_credential_id" bigint NULL,
  329. "registry_infra_provider" text NULL,
  330. "cluster_infra_id" bigint NULL,
  331. "cluster_infra_credential_id" bigint NULL,
  332. "cluster_infra_provider" text NULL,
  333. PRIMARY KEY ("id")
  334. );
  335. -- Create index "idx_onboardings_deleted_at" to table: "onboardings"
  336. CREATE INDEX "idx_onboardings_deleted_at" ON "public"."onboardings" ("deleted_at");
  337. -- Create "allowlists" table
  338. CREATE TABLE "public"."allowlists" (
  339. "id" bigserial NOT NULL,
  340. "created_at" timestamptz NULL,
  341. "updated_at" timestamptz NULL,
  342. "deleted_at" timestamptz NULL,
  343. "user_email" text NOT NULL,
  344. PRIMARY KEY ("id")
  345. );
  346. -- Create index "allowlists_user_email_key" to table: "allowlists"
  347. CREATE UNIQUE INDEX "allowlists_user_email_key" ON "public"."allowlists" ("user_email");
  348. -- Create index "idx_allowlists_deleted_at" to table: "allowlists"
  349. CREATE INDEX "idx_allowlists_deleted_at" ON "public"."allowlists" ("deleted_at");
  350. -- Create "pw_reset_tokens" table
  351. CREATE TABLE "public"."pw_reset_tokens" (
  352. "id" bigserial NOT NULL,
  353. "created_at" timestamptz NULL,
  354. "updated_at" timestamptz NULL,
  355. "deleted_at" timestamptz NULL,
  356. "email" text NULL,
  357. "is_valid" boolean NULL,
  358. "expiry" timestamptz NULL,
  359. "token" text NULL,
  360. PRIMARY KEY ("id")
  361. );
  362. -- Create index "idx_pw_reset_tokens_deleted_at" to table: "pw_reset_tokens"
  363. CREATE INDEX "idx_pw_reset_tokens_deleted_at" ON "public"."pw_reset_tokens" ("deleted_at");
  364. -- Create "projects" table
  365. CREATE TABLE "public"."projects" (
  366. "id" bigserial NOT NULL,
  367. "created_at" timestamptz NULL,
  368. "updated_at" timestamptz NULL,
  369. "deleted_at" timestamptz NULL,
  370. "name" text NULL,
  371. "project_usage_id" bigint NULL,
  372. "project_usage_cache_id" bigint NULL,
  373. "preview_envs_enabled" boolean NULL,
  374. "rds_databases_enabled" boolean NULL,
  375. "managed_infra_enabled" boolean NULL,
  376. "stacks_enabled" boolean NULL,
  377. "api_tokens_enabled" boolean NULL,
  378. "capi_provisioner_enabled" boolean NULL,
  379. "simplified_view_enabled" boolean NULL,
  380. PRIMARY KEY ("id")
  381. );
  382. -- Create index "idx_projects_deleted_at" to table: "projects"
  383. CREATE INDEX "idx_projects_deleted_at" ON "public"."projects" ("deleted_at");
  384. -- Create "job_notification_configs" table
  385. CREATE TABLE "public"."job_notification_configs" (
  386. "id" bigserial NOT NULL,
  387. "created_at" timestamptz NULL,
  388. "updated_at" timestamptz NULL,
  389. "deleted_at" timestamptz NULL,
  390. "name" text NULL,
  391. "namespace" text NULL,
  392. "project_id" bigint NULL,
  393. "cluster_id" bigint NULL,
  394. "last_notified_time" timestamptz NULL,
  395. PRIMARY KEY ("id")
  396. );
  397. -- Create index "idx_job_notification_configs_deleted_at" to table: "job_notification_configs"
  398. CREATE INDEX "idx_job_notification_configs_deleted_at" ON "public"."job_notification_configs" ("deleted_at");
  399. -- Create "github_app_installations" table
  400. CREATE TABLE "public"."github_app_installations" (
  401. "id" bigserial NOT NULL,
  402. "created_at" timestamptz NULL,
  403. "updated_at" timestamptz NULL,
  404. "deleted_at" timestamptz NULL,
  405. "account_id" bigint NULL,
  406. "installation_id" bigint NULL,
  407. PRIMARY KEY ("id")
  408. );
  409. -- Create index "github_app_installations_account_id_key" to table: "github_app_installations"
  410. CREATE UNIQUE INDEX "github_app_installations_account_id_key" ON "public"."github_app_installations" ("account_id");
  411. -- Create index "idx_github_app_installations_deleted_at" to table: "github_app_installations"
  412. CREATE INDEX "idx_github_app_installations_deleted_at" ON "public"."github_app_installations" ("deleted_at");
  413. -- Create "github_app_o_auth_integrations" table
  414. CREATE TABLE "public"."github_app_o_auth_integrations" (
  415. "id" bigserial NOT NULL,
  416. "created_at" timestamptz NULL,
  417. "updated_at" timestamptz NULL,
  418. "deleted_at" timestamptz NULL,
  419. "client_id" bytea NULL,
  420. "access_token" bytea NULL,
  421. "refresh_token" bytea NULL,
  422. "expiry" timestamptz NULL,
  423. "user_id" bigint NULL,
  424. PRIMARY KEY ("id")
  425. );
  426. -- Create index "idx_github_app_o_auth_integrations_deleted_at" to table: "github_app_o_auth_integrations"
  427. CREATE INDEX "idx_github_app_o_auth_integrations_deleted_at" ON "public"."github_app_o_auth_integrations" ("deleted_at");
  428. -- Create "gitlab_app_o_auth_integrations" table
  429. CREATE TABLE "public"."gitlab_app_o_auth_integrations" (
  430. "id" bigserial NOT NULL,
  431. "created_at" timestamptz NULL,
  432. "updated_at" timestamptz NULL,
  433. "deleted_at" timestamptz NULL,
  434. "o_auth_integration_id" bigint NULL,
  435. "gitlab_integration_id" bigint NULL,
  436. PRIMARY KEY ("id")
  437. );
  438. -- Create index "idx_gitlab_app_o_auth_integrations_deleted_at" to table: "gitlab_app_o_auth_integrations"
  439. CREATE INDEX "idx_gitlab_app_o_auth_integrations_deleted_at" ON "public"."gitlab_app_o_auth_integrations" ("deleted_at");
  440. -- Create "project_usages" table
  441. CREATE TABLE "public"."project_usages" (
  442. "id" bigserial NOT NULL,
  443. "created_at" timestamptz NULL,
  444. "updated_at" timestamptz NULL,
  445. "deleted_at" timestamptz NULL,
  446. "project_id" bigint NULL,
  447. "resource_cpu" bigint NULL,
  448. "resource_memory" bigint NULL,
  449. "clusters" bigint NULL,
  450. "users" bigint NULL,
  451. PRIMARY KEY ("id")
  452. );
  453. -- Create index "idx_project_usages_deleted_at" to table: "project_usages"
  454. CREATE INDEX "idx_project_usages_deleted_at" ON "public"."project_usages" ("deleted_at");
  455. -- Create "notification_configs" table
  456. CREATE TABLE "public"."notification_configs" (
  457. "id" bigserial NOT NULL,
  458. "created_at" timestamptz NULL,
  459. "updated_at" timestamptz NULL,
  460. "deleted_at" timestamptz NULL,
  461. "enabled" boolean NULL,
  462. "success" boolean NULL,
  463. "failure" boolean NULL,
  464. "last_notified_time" timestamptz NULL,
  465. "notif_limit" text NULL,
  466. PRIMARY KEY ("id")
  467. );
  468. -- Create index "idx_notification_configs_deleted_at" to table: "notification_configs"
  469. CREATE INDEX "idx_notification_configs_deleted_at" ON "public"."notification_configs" ("deleted_at");
  470. -- Create "monitor_test_results" table
  471. CREATE TABLE "public"."monitor_test_results" (
  472. "id" bigserial NOT NULL,
  473. "created_at" timestamptz NULL,
  474. "updated_at" timestamptz NULL,
  475. "deleted_at" timestamptz NULL,
  476. "project_id" bigint NULL,
  477. "cluster_id" bigint NULL,
  478. "category" text NULL,
  479. "object_id" text NULL,
  480. "last_status_change" timestamptz NULL,
  481. "last_tested" timestamptz NULL,
  482. "last_run_result" text NULL,
  483. "last_run_result_enum" bigint NULL,
  484. "last_recommender_run_id" text NULL,
  485. "archived" boolean NULL,
  486. "title" text NULL,
  487. "message" text NULL,
  488. "severity" text NULL,
  489. "severity_enum" bigint NULL,
  490. PRIMARY KEY ("id")
  491. );
  492. -- Create index "idx_monitor_test_results_deleted_at" to table: "monitor_test_results"
  493. CREATE INDEX "idx_monitor_test_results_deleted_at" ON "public"."monitor_test_results" ("deleted_at");
  494. -- Create "project_usage_caches" table
  495. CREATE TABLE "public"."project_usage_caches" (
  496. "id" bigserial NOT NULL,
  497. "created_at" timestamptz NULL,
  498. "updated_at" timestamptz NULL,
  499. "deleted_at" timestamptz NULL,
  500. "project_id" bigint NULL,
  501. "resource_cpu" bigint NULL,
  502. "resource_memory" bigint NULL,
  503. "clusters" bigint NULL,
  504. "users" bigint NULL,
  505. "exceeded" boolean NULL,
  506. "exceeded_since" timestamptz NULL,
  507. PRIMARY KEY ("id")
  508. );
  509. -- Create index "idx_project_usage_caches_deleted_at" to table: "project_usage_caches"
  510. CREATE INDEX "idx_project_usage_caches_deleted_at" ON "public"."project_usage_caches" ("deleted_at");
  511. -- Create "aws_integrations" table
  512. CREATE TABLE "public"."aws_integrations" (
  513. "id" bigserial NOT NULL,
  514. "created_at" timestamptz NULL,
  515. "updated_at" timestamptz NULL,
  516. "deleted_at" timestamptz NULL,
  517. "user_id" bigint NULL,
  518. "project_id" bigint NULL,
  519. "aws_arn" text NULL,
  520. "aws_region" text NULL,
  521. "aws_assume_role_arn" text NULL,
  522. "aws_cluster_id" bytea NULL,
  523. "aws_access_key_id" bytea NULL,
  524. "aws_secret_access_key" bytea NULL,
  525. "aws_session_token" bytea NULL,
  526. PRIMARY KEY ("id"),
  527. CONSTRAINT "fk_projects_aws_integrations" FOREIGN KEY ("project_id") REFERENCES "public"."projects" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
  528. );
  529. -- Create index "idx_aws_integrations_deleted_at" to table: "aws_integrations"
  530. CREATE INDEX "idx_aws_integrations_deleted_at" ON "public"."aws_integrations" ("deleted_at");
  531. -- Create "git_repos" table
  532. CREATE TABLE "public"."git_repos" (
  533. "id" bigserial NOT NULL,
  534. "created_at" timestamptz NULL,
  535. "updated_at" timestamptz NULL,
  536. "deleted_at" timestamptz NULL,
  537. "project_id" bigint NULL,
  538. "repo_entity" text NULL,
  539. "o_auth_integration_id" bigint NULL,
  540. PRIMARY KEY ("id"),
  541. CONSTRAINT "fk_projects_git_repos" FOREIGN KEY ("project_id") REFERENCES "public"."projects" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
  542. );
  543. -- Create index "idx_git_repos_deleted_at" to table: "git_repos"
  544. CREATE INDEX "idx_git_repos_deleted_at" ON "public"."git_repos" ("deleted_at");
  545. -- Create "infras" table
  546. CREATE TABLE "public"."infras" (
  547. "id" bigserial NOT NULL,
  548. "created_at" timestamptz NULL,
  549. "updated_at" timestamptz NULL,
  550. "deleted_at" timestamptz NULL,
  551. "kind" text NULL,
  552. "api_version" text NULL,
  553. "source_link" text NULL,
  554. "source_version" text NULL,
  555. "suffix" text NULL,
  556. "project_id" bigint NULL,
  557. "created_by_user_id" bigint NULL,
  558. "parent_cluster_id" bigint NULL,
  559. "status" text NULL,
  560. "aws_integration_id" bigint NULL,
  561. "azure_integration_id" bigint NULL,
  562. "gcp_integration_id" bigint NULL,
  563. "do_integration_id" bigint NULL,
  564. "database_id" bigint NULL,
  565. "last_applied" bytea NULL,
  566. PRIMARY KEY ("id"),
  567. CONSTRAINT "fk_projects_infras" FOREIGN KEY ("project_id") REFERENCES "public"."projects" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
  568. );
  569. -- Create index "idx_infras_deleted_at" to table: "infras"
  570. CREATE INDEX "idx_infras_deleted_at" ON "public"."infras" ("deleted_at");
  571. -- Create "operations" table
  572. CREATE TABLE "public"."operations" (
  573. "id" bigserial NOT NULL,
  574. "created_at" timestamptz NULL,
  575. "updated_at" timestamptz NULL,
  576. "deleted_at" timestamptz NULL,
  577. "uid" text NULL,
  578. "infra_id" bigint NULL,
  579. "type" text NULL,
  580. "status" text NULL,
  581. "errored" boolean NULL,
  582. "error" text NULL,
  583. "template_version" text NULL,
  584. "last_applied" bytea NULL,
  585. PRIMARY KEY ("id"),
  586. CONSTRAINT "fk_infras_operations" FOREIGN KEY ("infra_id") REFERENCES "public"."infras" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
  587. );
  588. -- Create index "idx_operations_deleted_at" to table: "operations"
  589. CREATE INDEX "idx_operations_deleted_at" ON "public"."operations" ("deleted_at");
  590. -- Create index "operations_uid_key" to table: "operations"
  591. CREATE UNIQUE INDEX "operations_uid_key" ON "public"."operations" ("uid");
  592. -- Create "cluster_candidates" table
  593. CREATE TABLE "public"."cluster_candidates" (
  594. "id" bigserial NOT NULL,
  595. "created_at" timestamptz NULL,
  596. "updated_at" timestamptz NULL,
  597. "deleted_at" timestamptz NULL,
  598. "auth_mechanism" text NULL,
  599. "project_id" bigint NULL,
  600. "created_cluster_id" bigint NULL,
  601. "name" text NULL,
  602. "server" text NULL,
  603. "context_name" text NULL,
  604. "aws_cluster_id_guess" bytea NULL,
  605. "kubeconfig" bytea NULL,
  606. PRIMARY KEY ("id"),
  607. CONSTRAINT "fk_projects_cluster_candidates" FOREIGN KEY ("project_id") REFERENCES "public"."projects" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
  608. );
  609. -- Create index "idx_cluster_candidates_deleted_at" to table: "cluster_candidates"
  610. CREATE INDEX "idx_cluster_candidates_deleted_at" ON "public"."cluster_candidates" ("deleted_at");
  611. -- Create "cluster_resolvers" table
  612. CREATE TABLE "public"."cluster_resolvers" (
  613. "id" bigserial NOT NULL,
  614. "created_at" timestamptz NULL,
  615. "updated_at" timestamptz NULL,
  616. "deleted_at" timestamptz NULL,
  617. "cluster_candidate_id" bigint NULL,
  618. "name" text NULL,
  619. "resolved" boolean NULL,
  620. "data" bytea NULL,
  621. PRIMARY KEY ("id"),
  622. CONSTRAINT "fk_cluster_candidates_resolvers" FOREIGN KEY ("cluster_candidate_id") REFERENCES "public"."cluster_candidates" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
  623. );
  624. -- Create index "idx_cluster_resolvers_deleted_at" to table: "cluster_resolvers"
  625. CREATE INDEX "idx_cluster_resolvers_deleted_at" ON "public"."cluster_resolvers" ("deleted_at");
  626. -- Create "helm_repos" table
  627. CREATE TABLE "public"."helm_repos" (
  628. "id" bigserial NOT NULL,
  629. "created_at" timestamptz NULL,
  630. "updated_at" timestamptz NULL,
  631. "deleted_at" timestamptz NULL,
  632. "name" text NULL,
  633. "project_id" bigint NULL,
  634. "repo_url" text NULL,
  635. "basic_auth_integration_id" bigint NULL,
  636. "gcp_integration_id" bigint NULL,
  637. "aws_integration_id" bigint NULL,
  638. PRIMARY KEY ("id"),
  639. CONSTRAINT "fk_projects_helm_repos" FOREIGN KEY ("project_id") REFERENCES "public"."projects" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
  640. );
  641. -- Create index "idx_helm_repos_deleted_at" to table: "helm_repos"
  642. CREATE INDEX "idx_helm_repos_deleted_at" ON "public"."helm_repos" ("deleted_at");
  643. -- Create "helm_repo_token_caches" table
  644. CREATE TABLE "public"."helm_repo_token_caches" (
  645. "id" bigserial NOT NULL,
  646. "created_at" timestamptz NULL,
  647. "updated_at" timestamptz NULL,
  648. "deleted_at" timestamptz NULL,
  649. "expiry" timestamptz NULL,
  650. "token" bytea NULL,
  651. "helm_repo_id" bigint NULL,
  652. PRIMARY KEY ("id"),
  653. CONSTRAINT "fk_helm_repos_token_cache" FOREIGN KEY ("helm_repo_id") REFERENCES "public"."helm_repos" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
  654. );
  655. -- Create index "idx_helm_repo_token_caches_deleted_at" to table: "helm_repo_token_caches"
  656. CREATE INDEX "idx_helm_repo_token_caches_deleted_at" ON "public"."helm_repo_token_caches" ("deleted_at");
  657. -- Create "o_auth_integrations" table
  658. CREATE TABLE "public"."o_auth_integrations" (
  659. "id" bigserial NOT NULL,
  660. "created_at" timestamptz NULL,
  661. "updated_at" timestamptz NULL,
  662. "deleted_at" timestamptz NULL,
  663. "client_id" bytea NULL,
  664. "access_token" bytea NULL,
  665. "refresh_token" bytea NULL,
  666. "expiry" timestamptz NULL,
  667. "client" text NULL,
  668. "user_id" bigint NULL,
  669. "project_id" bigint NULL,
  670. "target_email" text NULL,
  671. "target_name" text NULL,
  672. PRIMARY KEY ("id"),
  673. CONSTRAINT "fk_projects_o_auth_integrations" FOREIGN KEY ("project_id") REFERENCES "public"."projects" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
  674. );
  675. -- Create index "idx_o_auth_integrations_deleted_at" to table: "o_auth_integrations"
  676. CREATE INDEX "idx_o_auth_integrations_deleted_at" ON "public"."o_auth_integrations" ("deleted_at");
  677. -- Create "registries" table
  678. CREATE TABLE "public"."registries" (
  679. "id" bigserial NOT NULL,
  680. "created_at" timestamptz NULL,
  681. "updated_at" timestamptz NULL,
  682. "deleted_at" timestamptz NULL,
  683. "name" text NULL,
  684. "url" text NULL,
  685. "project_id" bigint NULL,
  686. "infra_id" bigint NULL,
  687. "gcp_integration_id" bigint NULL,
  688. "aws_integration_id" bigint NULL,
  689. "azure_integration_id" bigint NULL,
  690. "do_integration_id" bigint NULL,
  691. "basic_integration_id" bigint NULL,
  692. PRIMARY KEY ("id"),
  693. CONSTRAINT "fk_projects_registries" FOREIGN KEY ("project_id") REFERENCES "public"."projects" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
  694. );
  695. -- Create index "idx_registries_deleted_at" to table: "registries"
  696. CREATE INDEX "idx_registries_deleted_at" ON "public"."registries" ("deleted_at");
  697. -- Create "reg_token_caches" table
  698. CREATE TABLE "public"."reg_token_caches" (
  699. "id" bigserial NOT NULL,
  700. "created_at" timestamptz NULL,
  701. "updated_at" timestamptz NULL,
  702. "deleted_at" timestamptz NULL,
  703. "expiry" timestamptz NULL,
  704. "token" bytea NULL,
  705. "registry_id" bigint NULL,
  706. PRIMARY KEY ("id"),
  707. CONSTRAINT "fk_registries_token_cache" FOREIGN KEY ("registry_id") REFERENCES "public"."registries" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
  708. );
  709. -- Create index "idx_reg_token_caches_deleted_at" to table: "reg_token_caches"
  710. CREATE INDEX "idx_reg_token_caches_deleted_at" ON "public"."reg_token_caches" ("deleted_at");
  711. -- Create "event_containers" table
  712. CREATE TABLE "public"."event_containers" (
  713. "id" bigserial NOT NULL,
  714. "created_at" timestamptz NULL,
  715. "updated_at" timestamptz NULL,
  716. "deleted_at" timestamptz NULL,
  717. "release_id" bigint NULL,
  718. PRIMARY KEY ("id")
  719. );
  720. -- Create index "idx_event_containers_deleted_at" to table: "event_containers"
  721. CREATE INDEX "idx_event_containers_deleted_at" ON "public"."event_containers" ("deleted_at");
  722. -- Create "sub_events" table
  723. CREATE TABLE "public"."sub_events" (
  724. "id" bigserial NOT NULL,
  725. "created_at" timestamptz NULL,
  726. "updated_at" timestamptz NULL,
  727. "deleted_at" timestamptz NULL,
  728. "event_container_id" bigint NULL,
  729. "event_id" text NULL,
  730. "name" text NULL,
  731. "index" bigint NULL,
  732. "status" bigint NULL,
  733. "info" text NULL,
  734. PRIMARY KEY ("id"),
  735. CONSTRAINT "fk_event_containers_steps" FOREIGN KEY ("event_container_id") REFERENCES "public"."event_containers" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
  736. );
  737. -- Create index "idx_sub_events_deleted_at" to table: "sub_events"
  738. CREATE INDEX "idx_sub_events_deleted_at" ON "public"."sub_events" ("deleted_at");
  739. -- Create "kube_integrations" table
  740. CREATE TABLE "public"."kube_integrations" (
  741. "id" bigserial NOT NULL,
  742. "created_at" timestamptz NULL,
  743. "updated_at" timestamptz NULL,
  744. "deleted_at" timestamptz NULL,
  745. "mechanism" text NULL,
  746. "user_id" bigint NULL,
  747. "project_id" bigint NULL,
  748. "client_certificate_data" bytea NULL,
  749. "client_key_data" bytea NULL,
  750. "token" bytea NULL,
  751. "username" bytea NULL,
  752. "password" bytea NULL,
  753. "kubeconfig" bytea NULL,
  754. PRIMARY KEY ("id"),
  755. CONSTRAINT "fk_projects_kube_integrations" FOREIGN KEY ("project_id") REFERENCES "public"."projects" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
  756. );
  757. -- Create index "idx_kube_integrations_deleted_at" to table: "kube_integrations"
  758. CREATE INDEX "idx_kube_integrations_deleted_at" ON "public"."kube_integrations" ("deleted_at");
  759. -- Create "o_id_c_integrations" table
  760. CREATE TABLE "public"."o_id_c_integrations" (
  761. "id" bigserial NOT NULL,
  762. "created_at" timestamptz NULL,
  763. "updated_at" timestamptz NULL,
  764. "deleted_at" timestamptz NULL,
  765. "client" text NULL,
  766. "user_id" bigint NULL,
  767. "project_id" bigint NULL,
  768. "issuer_url" bytea NULL,
  769. "client_id" bytea NULL,
  770. "client_secret" bytea NULL,
  771. "certificate_authority_data" bytea NULL,
  772. "id_token" bytea NULL,
  773. "refresh_token" bytea NULL,
  774. PRIMARY KEY ("id"),
  775. CONSTRAINT "fk_projects_o_id_c_integrations" FOREIGN KEY ("project_id") REFERENCES "public"."projects" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
  776. );
  777. -- Create index "idx_o_id_c_integrations_deleted_at" to table: "o_id_c_integrations"
  778. CREATE INDEX "idx_o_id_c_integrations_deleted_at" ON "public"."o_id_c_integrations" ("deleted_at");
  779. -- Create "releases" table
  780. CREATE TABLE "public"."releases" (
  781. "id" bigserial NOT NULL,
  782. "created_at" timestamptz NULL,
  783. "updated_at" timestamptz NULL,
  784. "deleted_at" timestamptz NULL,
  785. "webhook_token" text NULL,
  786. "cluster_id" bigint NULL,
  787. "project_id" bigint NULL,
  788. "name" text NULL,
  789. "namespace" text NULL,
  790. "stack_resource_id" bigint NULL,
  791. "image_repo_uri" text NULL,
  792. "event_container" bigint NULL,
  793. "notification_config" bigint NULL,
  794. "build_config" bigint NULL,
  795. "canonical_name" text NULL,
  796. PRIMARY KEY ("id")
  797. );
  798. -- Create index "idx_releases_deleted_at" to table: "releases"
  799. CREATE INDEX "idx_releases_deleted_at" ON "public"."releases" ("deleted_at");
  800. -- Create index "releases_webhook_token_key" to table: "releases"
  801. CREATE UNIQUE INDEX "releases_webhook_token_key" ON "public"."releases" ("webhook_token");
  802. -- Create "git_action_configs" table
  803. CREATE TABLE "public"."git_action_configs" (
  804. "id" bigserial NOT NULL,
  805. "created_at" timestamptz NULL,
  806. "updated_at" timestamptz NULL,
  807. "deleted_at" timestamptz NULL,
  808. "release_id" bigint NULL,
  809. "git_repo" text NULL,
  810. "git_branch" text NULL,
  811. "image_repo_uri" text NULL,
  812. "github_installation_id" bigint NULL,
  813. "git_repo_id" bigint NULL,
  814. "gitlab_integration_id" bigint NULL,
  815. "dockerfile_path" text NULL,
  816. "folder_path" text NULL,
  817. "is_installation" boolean NULL,
  818. "version" text NULL DEFAULT 'v0.0.1',
  819. PRIMARY KEY ("id"),
  820. CONSTRAINT "fk_releases_git_action_config" FOREIGN KEY ("release_id") REFERENCES "public"."releases" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
  821. );
  822. -- Create index "idx_git_action_configs_deleted_at" to table: "git_action_configs"
  823. CREATE INDEX "idx_git_action_configs_deleted_at" ON "public"."git_action_configs" ("deleted_at");
  824. -- Create "kube_events" table
  825. CREATE TABLE "public"."kube_events" (
  826. "id" bigserial NOT NULL,
  827. "created_at" timestamptz NULL,
  828. "updated_at" timestamptz NULL,
  829. "deleted_at" timestamptz NULL,
  830. "project_id" bigint NULL,
  831. "cluster_id" bigint NULL,
  832. "name" text NULL,
  833. "resource_type" text NULL,
  834. "owner_type" text NULL,
  835. "owner_name" text NULL,
  836. "namespace" text NULL,
  837. PRIMARY KEY ("id")
  838. );
  839. -- Create index "idx_kube_events_deleted_at" to table: "kube_events"
  840. CREATE INDEX "idx_kube_events_deleted_at" ON "public"."kube_events" ("deleted_at");
  841. -- Create "kube_sub_events" table
  842. CREATE TABLE "public"."kube_sub_events" (
  843. "id" bigserial NOT NULL,
  844. "created_at" timestamptz NULL,
  845. "updated_at" timestamptz NULL,
  846. "deleted_at" timestamptz NULL,
  847. "kube_event_id" bigint NULL,
  848. "message" text NULL,
  849. "reason" text NULL,
  850. "timestamp" timestamptz NULL,
  851. "event_type" text NULL,
  852. PRIMARY KEY ("id"),
  853. CONSTRAINT "fk_kube_events_sub_events" FOREIGN KEY ("kube_event_id") REFERENCES "public"."kube_events" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
  854. );
  855. -- Create index "idx_kube_sub_events_deleted_at" to table: "kube_sub_events"
  856. CREATE INDEX "idx_kube_sub_events_deleted_at" ON "public"."kube_sub_events" ("deleted_at");
  857. -- Create "tags" table
  858. CREATE TABLE "public"."tags" (
  859. "id" bigserial NOT NULL,
  860. "created_at" timestamptz NULL,
  861. "updated_at" timestamptz NULL,
  862. "deleted_at" timestamptz NULL,
  863. "project_id" bigint NULL,
  864. "name" text NULL,
  865. "color" text NULL,
  866. PRIMARY KEY ("id")
  867. );
  868. -- Create index "idx_tags_deleted_at" to table: "tags"
  869. CREATE INDEX "idx_tags_deleted_at" ON "public"."tags" ("deleted_at");
  870. -- Create "release_tags" table
  871. CREATE TABLE "public"."release_tags" (
  872. "tag_id" bigint NOT NULL,
  873. "release_id" bigint NOT NULL,
  874. PRIMARY KEY ("tag_id", "release_id"),
  875. CONSTRAINT "fk_release_tags_release" FOREIGN KEY ("release_id") REFERENCES "public"."releases" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION,
  876. CONSTRAINT "fk_release_tags_tag" FOREIGN KEY ("tag_id") REFERENCES "public"."tags" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
  877. );
  878. -- Create "stacks" table
  879. CREATE TABLE "public"."stacks" (
  880. "id" bigserial NOT NULL,
  881. "created_at" timestamptz NULL,
  882. "updated_at" timestamptz NULL,
  883. "deleted_at" timestamptz NULL,
  884. "project_id" bigint NULL,
  885. "cluster_id" bigint NULL,
  886. "namespace" text NULL,
  887. "name" text NULL,
  888. "uid" text NULL,
  889. PRIMARY KEY ("id")
  890. );
  891. -- Create index "idx_stacks_deleted_at" to table: "stacks"
  892. CREATE INDEX "idx_stacks_deleted_at" ON "public"."stacks" ("deleted_at");
  893. -- Create index "stacks_uid_key" to table: "stacks"
  894. CREATE UNIQUE INDEX "stacks_uid_key" ON "public"."stacks" ("uid");
  895. -- Create "stack_revisions" table
  896. CREATE TABLE "public"."stack_revisions" (
  897. "id" bigserial NOT NULL,
  898. "created_at" timestamptz NULL,
  899. "updated_at" timestamptz NULL,
  900. "deleted_at" timestamptz NULL,
  901. "revision_number" bigint NULL,
  902. "stack_id" bigint NULL,
  903. "status" text NULL,
  904. "reason" text NULL,
  905. "message" text NULL,
  906. PRIMARY KEY ("id"),
  907. CONSTRAINT "fk_stacks_revisions" FOREIGN KEY ("stack_id") REFERENCES "public"."stacks" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
  908. );
  909. -- Create index "idx_stack_revisions_deleted_at" to table: "stack_revisions"
  910. CREATE INDEX "idx_stack_revisions_deleted_at" ON "public"."stack_revisions" ("deleted_at");
  911. -- Create "stack_env_groups" table
  912. CREATE TABLE "public"."stack_env_groups" (
  913. "id" bigserial NOT NULL,
  914. "created_at" timestamptz NULL,
  915. "updated_at" timestamptz NULL,
  916. "deleted_at" timestamptz NULL,
  917. "stack_revision_id" bigint NULL,
  918. "name" text NULL,
  919. "namespace" text NULL,
  920. "project_id" bigint NULL,
  921. "cluster_id" bigint NULL,
  922. "uid" text NULL,
  923. "env_group_version" bigint NULL,
  924. PRIMARY KEY ("id"),
  925. CONSTRAINT "fk_stack_revisions_env_groups" FOREIGN KEY ("stack_revision_id") REFERENCES "public"."stack_revisions" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
  926. );
  927. -- Create index "idx_stack_env_groups_deleted_at" to table: "stack_env_groups"
  928. CREATE INDEX "idx_stack_env_groups_deleted_at" ON "public"."stack_env_groups" ("deleted_at");
  929. -- Create "stack_resources" table
  930. CREATE TABLE "public"."stack_resources" (
  931. "id" bigserial NOT NULL,
  932. "created_at" timestamptz NULL,
  933. "updated_at" timestamptz NULL,
  934. "deleted_at" timestamptz NULL,
  935. "name" text NULL,
  936. "uid" text NULL,
  937. "stack_revision_id" bigint NULL,
  938. "stack_source_config_uid" text NULL,
  939. "helm_revision_id" bigint NULL,
  940. "values" bytea NULL,
  941. "template_repo_url" text NULL,
  942. "template_name" text NULL,
  943. "template_version" text NULL,
  944. PRIMARY KEY ("id"),
  945. CONSTRAINT "fk_stack_revisions_resources" FOREIGN KEY ("stack_revision_id") REFERENCES "public"."stack_revisions" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
  946. );
  947. -- Create index "idx_stack_resources_deleted_at" to table: "stack_resources"
  948. CREATE INDEX "idx_stack_resources_deleted_at" ON "public"."stack_resources" ("deleted_at");
  949. -- Create "azure_integrations" table
  950. CREATE TABLE "public"."azure_integrations" (
  951. "id" bigserial NOT NULL,
  952. "created_at" timestamptz NULL,
  953. "updated_at" timestamptz NULL,
  954. "deleted_at" timestamptz NULL,
  955. "user_id" bigint NULL,
  956. "project_id" bigint NULL,
  957. "azure_client_id" text NULL,
  958. "azure_subscription_id" text NULL,
  959. "azure_tenant_id" text NULL,
  960. "acr_token_name" text NULL,
  961. "acr_resource_group_name" text NULL,
  962. "acr_name" text NULL,
  963. "service_principal_secret" bytea NULL,
  964. "acr_password1" bytea NULL,
  965. "acr_password2" bytea NULL,
  966. "aks_password" bytea NULL,
  967. PRIMARY KEY ("id"),
  968. CONSTRAINT "fk_projects_azure_integrations" FOREIGN KEY ("project_id") REFERENCES "public"."projects" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
  969. );
  970. -- Create index "idx_azure_integrations_deleted_at" to table: "azure_integrations"
  971. CREATE INDEX "idx_azure_integrations_deleted_at" ON "public"."azure_integrations" ("deleted_at");
  972. -- Create "stack_source_configs" table
  973. CREATE TABLE "public"."stack_source_configs" (
  974. "id" bigserial NOT NULL,
  975. "created_at" timestamptz NULL,
  976. "updated_at" timestamptz NULL,
  977. "deleted_at" timestamptz NULL,
  978. "stack_revision_id" bigint NULL,
  979. "name" text NULL,
  980. "display_name" text NULL,
  981. "uid" text NULL,
  982. "image_repo_uri" text NULL,
  983. "image_tag" text NULL,
  984. PRIMARY KEY ("id"),
  985. CONSTRAINT "fk_stack_revisions_source_configs" FOREIGN KEY ("stack_revision_id") REFERENCES "public"."stack_revisions" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
  986. );
  987. -- Create index "idx_stack_source_configs_deleted_at" to table: "stack_source_configs"
  988. CREATE INDEX "idx_stack_source_configs_deleted_at" ON "public"."stack_source_configs" ("deleted_at");
  989. -- Create "aws_assume_role_chains" table
  990. CREATE TABLE "public"."aws_assume_role_chains" (
  991. "id" uuid NOT NULL,
  992. "created_at" timestamptz NULL,
  993. "updated_at" timestamptz NULL,
  994. "deleted_at" timestamptz NULL,
  995. "project_id" bigint NULL,
  996. "source_arn" text NULL,
  997. "target_arn" text NULL,
  998. "external_id" text NULL,
  999. PRIMARY KEY ("id"),
  1000. CONSTRAINT "fk_projects" FOREIGN KEY ("project_id") REFERENCES "public"."projects" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
  1001. );
  1002. -- Create index "aws_assume_role_chains_project_id_source_arn_target_arn_key" to table: "aws_assume_role_chains"
  1003. CREATE UNIQUE INDEX "aws_assume_role_chains_project_id_source_arn_target_arn_key" ON "public"."aws_assume_role_chains" ("project_id", "source_arn", "target_arn");
  1004. -- Create index "aws_assume_role_chains_project_id_source_arn_target_arn_key1" to table: "aws_assume_role_chains"
  1005. CREATE UNIQUE INDEX "aws_assume_role_chains_project_id_source_arn_target_arn_key1" ON "public"."aws_assume_role_chains" ("project_id", "source_arn", "target_arn");
  1006. -- Create index "aws_assume_role_chains_project_id_source_arn_target_arn_key2" to table: "aws_assume_role_chains"
  1007. CREATE UNIQUE INDEX "aws_assume_role_chains_project_id_source_arn_target_arn_key2" ON "public"."aws_assume_role_chains" ("project_id", "source_arn", "target_arn");
  1008. -- Create index "aws_assume_role_chains_project_id_source_arn_target_arn_key3" to table: "aws_assume_role_chains"
  1009. CREATE UNIQUE INDEX "aws_assume_role_chains_project_id_source_arn_target_arn_key3" ON "public"."aws_assume_role_chains" ("project_id", "source_arn", "target_arn");
  1010. -- Create index "aws_assume_role_chains_project_id_source_arn_target_arn_key4" to table: "aws_assume_role_chains"
  1011. CREATE UNIQUE INDEX "aws_assume_role_chains_project_id_source_arn_target_arn_key4" ON "public"."aws_assume_role_chains" ("project_id", "source_arn", "target_arn");
  1012. -- Create index "idx_aws_assume_role_chains_deleted_at" to table: "aws_assume_role_chains"
  1013. CREATE INDEX "idx_aws_assume_role_chains_deleted_at" ON "public"."aws_assume_role_chains" ("deleted_at");
  1014. -- Create "clusters" table
  1015. CREATE TABLE "public"."clusters" (
  1016. "id" bigserial NOT NULL,
  1017. "created_at" timestamptz NULL,
  1018. "updated_at" timestamptz NULL,
  1019. "deleted_at" timestamptz NULL,
  1020. "auth_mechanism" text NULL,
  1021. "project_id" bigint NULL,
  1022. "agent_integration_enabled" boolean NULL,
  1023. "name" text NULL,
  1024. "vanity_name" text NULL,
  1025. "server" text NULL,
  1026. "cluster_location_of_origin" text NULL,
  1027. "tls_server_name" text NULL,
  1028. "insecure_skip_tls_verify" boolean NULL,
  1029. "proxy_url" text NULL,
  1030. "user_location_of_origin" text NULL,
  1031. "user_impersonate" text NULL,
  1032. "user_impersonate_groups" text NULL,
  1033. "infra_id" bigint NULL,
  1034. "notifications_disabled" boolean NULL,
  1035. "preview_envs_enabled" boolean NULL,
  1036. "aws_cluster_id" text NULL,
  1037. "status" text NULL,
  1038. "provisioned_by" text NULL,
  1039. "cloud_provider" text NULL,
  1040. "cloud_provider_credential_identifier" text NULL,
  1041. "kube_integration_id" bigint NULL,
  1042. "o_id_c_integration_id" bigint NULL,
  1043. "gcp_integration_id" bigint NULL,
  1044. "aws_integration_id" bigint NULL,
  1045. "do_integration_id" bigint NULL,
  1046. "azure_integration_id" bigint NULL,
  1047. "token_cache_id" bigint NULL,
  1048. "certificate_authority_data" bytea NULL,
  1049. "monitor_helm_releases" boolean NULL,
  1050. PRIMARY KEY ("id"),
  1051. CONSTRAINT "fk_projects_clusters" FOREIGN KEY ("project_id") REFERENCES "public"."projects" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
  1052. );
  1053. -- Create index "idx_clusters_deleted_at" to table: "clusters"
  1054. CREATE INDEX "idx_clusters_deleted_at" ON "public"."clusters" ("deleted_at");
  1055. -- Create "gcp_integrations" table
  1056. CREATE TABLE "public"."gcp_integrations" (
  1057. "id" bigserial NOT NULL,
  1058. "created_at" timestamptz NULL,
  1059. "updated_at" timestamptz NULL,
  1060. "deleted_at" timestamptz NULL,
  1061. "user_id" bigint NULL,
  1062. "project_id" bigint NULL,
  1063. "gcp_project_id" text NULL,
  1064. "gcpsa_email" text NULL,
  1065. "g_cpuser_email" text NULL,
  1066. "gcp_region" text NULL,
  1067. "gcp_key_data" bytea NULL,
  1068. PRIMARY KEY ("id"),
  1069. CONSTRAINT "fk_projects_gcp_integrations" FOREIGN KEY ("project_id") REFERENCES "public"."projects" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
  1070. );
  1071. -- Create index "idx_gcp_integrations_deleted_at" to table: "gcp_integrations"
  1072. CREATE INDEX "idx_gcp_integrations_deleted_at" ON "public"."gcp_integrations" ("deleted_at");
  1073. -- Create "invites" table
  1074. CREATE TABLE "public"."invites" (
  1075. "id" bigserial NOT NULL,
  1076. "created_at" timestamptz NULL,
  1077. "updated_at" timestamptz NULL,
  1078. "deleted_at" timestamptz NULL,
  1079. "token" text NULL,
  1080. "expiry" timestamptz NULL,
  1081. "email" text NULL,
  1082. "kind" text NULL,
  1083. "project_id" bigint NULL,
  1084. "user_id" bigint NULL,
  1085. PRIMARY KEY ("id"),
  1086. CONSTRAINT "fk_projects_invites" FOREIGN KEY ("project_id") REFERENCES "public"."projects" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
  1087. );
  1088. -- Create index "idx_invites_deleted_at" to table: "invites"
  1089. CREATE INDEX "idx_invites_deleted_at" ON "public"."invites" ("deleted_at");
  1090. -- Create index "invites_token_key" to table: "invites"
  1091. CREATE UNIQUE INDEX "invites_token_key" ON "public"."invites" ("token");
  1092. -- Create "roles" table
  1093. CREATE TABLE "public"."roles" (
  1094. "id" bigserial NOT NULL,
  1095. "created_at" timestamptz NULL,
  1096. "updated_at" timestamptz NULL,
  1097. "deleted_at" timestamptz NULL,
  1098. "kind" text NULL,
  1099. "user_id" bigint NULL,
  1100. "project_id" bigint NULL,
  1101. PRIMARY KEY ("id"),
  1102. CONSTRAINT "fk_projects_roles" FOREIGN KEY ("project_id") REFERENCES "public"."projects" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
  1103. );
  1104. -- Create index "idx_roles_deleted_at" to table: "roles"
  1105. CREATE INDEX "idx_roles_deleted_at" ON "public"."roles" ("deleted_at");
  1106. -- Create "basic_integrations" table
  1107. CREATE TABLE "public"."basic_integrations" (
  1108. "id" bigserial NOT NULL,
  1109. "created_at" timestamptz NULL,
  1110. "updated_at" timestamptz NULL,
  1111. "deleted_at" timestamptz NULL,
  1112. "user_id" bigint NULL,
  1113. "project_id" bigint NULL,
  1114. "username" bytea NULL,
  1115. "password" bytea NULL,
  1116. PRIMARY KEY ("id"),
  1117. CONSTRAINT "fk_projects_basic_integrations" FOREIGN KEY ("project_id") REFERENCES "public"."projects" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
  1118. );
  1119. -- Create index "idx_basic_integrations_deleted_at" to table: "basic_integrations"
  1120. CREATE INDEX "idx_basic_integrations_deleted_at" ON "public"."basic_integrations" ("deleted_at");
  1121. -- Create "databases" table
  1122. CREATE TABLE "public"."databases" (
  1123. "id" bigserial NOT NULL,
  1124. "created_at" timestamptz NULL,
  1125. "updated_at" timestamptz NULL,
  1126. "deleted_at" timestamptz NULL,
  1127. "project_id" bigint NULL,
  1128. "cluster_id" bigint NULL,
  1129. "infra_id" bigint NULL,
  1130. "instance_id" text NULL,
  1131. "instance_endpoint" text NULL,
  1132. "instance_name" text NULL,
  1133. "status" text NULL,
  1134. PRIMARY KEY ("id"),
  1135. CONSTRAINT "fk_infras_database" FOREIGN KEY ("infra_id") REFERENCES "public"."infras" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION,
  1136. CONSTRAINT "fk_projects_databases" FOREIGN KEY ("project_id") REFERENCES "public"."projects" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
  1137. );
  1138. -- Create index "idx_databases_deleted_at" to table: "databases"
  1139. CREATE INDEX "idx_databases_deleted_at" ON "public"."databases" ("deleted_at");
  1140. -- Create "gitlab_integrations" table
  1141. CREATE TABLE "public"."gitlab_integrations" (
  1142. "id" bigserial NOT NULL,
  1143. "created_at" timestamptz NULL,
  1144. "updated_at" timestamptz NULL,
  1145. "deleted_at" timestamptz NULL,
  1146. "project_id" bigint NULL,
  1147. "instance_url" text NULL,
  1148. "app_client_id" bytea NULL,
  1149. "app_client_secret" bytea NULL,
  1150. PRIMARY KEY ("id"),
  1151. CONSTRAINT "fk_projects_gitlab_integrations" FOREIGN KEY ("project_id") REFERENCES "public"."projects" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
  1152. );
  1153. -- Create index "idx_gitlab_integrations_deleted_at" to table: "gitlab_integrations"
  1154. CREATE INDEX "idx_gitlab_integrations_deleted_at" ON "public"."gitlab_integrations" ("deleted_at");