schema.sql 46 KB

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