Skip to content

Commit 6624a39

Browse files
wip
1 parent 8a94aeb commit 6624a39

File tree

1 file changed

+177
-0
lines changed

1 file changed

+177
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
-- Create "digger_batches" table
2+
CREATE TABLE IF NOT EXISTS "public"."digger_batches" (
3+
"id" uuid NOT NULL DEFAULT gen_random_uuid(),
4+
"pr_number" bigint,
5+
"status" smallint NOT NULL,
6+
"branch_name" text NOT NULL,
7+
"digger_config" text,
8+
"github_installation_id" bigint,
9+
"repo_full_name" text NOT NULL,
10+
"repo_owner" text NOT NULL,
11+
"repo_name" text NOT NULL,
12+
"batch_type" text NOT NULL,
13+
"comment_id" bigint,
14+
"source_details" bytea,
15+
"vcs" text,
16+
"gitlab_project_id" bigint,
17+
PRIMARY KEY ("id")
18+
);
19+
20+
-- Create "digger_job_summaries" table
21+
CREATE TABLE IF NOT EXISTS "public"."digger_job_summaries" (
22+
"id" uuid NOT NULL DEFAULT gen_random_uuid(),
23+
"created_at" timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP,
24+
"updated_at" timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP,
25+
"deleted_at" timestamptz,
26+
"resources_created" bigint NOT NULL DEFAULT 0,
27+
"resources_deleted" bigint NOT NULL DEFAULT 0,
28+
"resources_updated" bigint NOT NULL DEFAULT 0,
29+
PRIMARY KEY ("id")
30+
);
31+
32+
-- Create index "idx_digger_job_summaries_deleted_at" to table: "digger_job_summaries"
33+
CREATE INDEX IF NOT EXISTS "idx_digger_job_summaries_deleted_at" ON "public"."digger_job_summaries" ("deleted_at");
34+
35+
-- Create "digger_jobs" table
36+
CREATE TABLE IF NOT EXISTS "public"."digger_jobs" (
37+
"id" uuid NOT NULL DEFAULT gen_random_uuid(),
38+
"created_at" timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP,
39+
"updated_at" timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP,
40+
"deleted_at" timestamptz,
41+
"digger_job_id" text NOT NULL,
42+
"status" smallint NOT NULL,
43+
"batch_id" uuid NOT NULL,
44+
"status_updated_at" timestamptz,
45+
"digger_job_summary_id" uuid,
46+
"workflow_file" text,
47+
"workflow_run_url" text,
48+
"plan_footprint" bytea,
49+
"pr_comment_url" text,
50+
"terraform_output" text,
51+
PRIMARY KEY ("id"),
52+
CONSTRAINT "fk_digger_jobs_batch" FOREIGN KEY ("batch_id") REFERENCES "public"."digger_batches" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION,
53+
CONSTRAINT "fk_digger_jobs_digger_job_summary" FOREIGN KEY ("digger_job_summary_id") REFERENCES "public"."digger_job_summaries" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
54+
);
55+
56+
-- Create index "idx_digger_jobs_deleted_at" to table: "digger_jobs"
57+
CREATE INDEX IF NOT EXISTS "idx_digger_jobs_deleted_at" ON "public"."digger_jobs" ("deleted_at");
58+
59+
-- Create index "idx_digger_job_id" to table: "digger_jobs"
60+
CREATE INDEX IF NOT EXISTS "idx_digger_job_id" ON "public"."digger_jobs" ("batch_id");
61+
62+
-- Create "digger_locks" table
63+
CREATE TABLE IF NOT EXISTS "public"."digger_locks" (
64+
"id" uuid NOT NULL DEFAULT gen_random_uuid(),
65+
"created_at" timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP,
66+
"updated_at" timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP,
67+
"deleted_at" timestamptz,
68+
"resource" text NOT NULL,
69+
"lock_id" bigint NOT NULL,
70+
"organization_id" uuid NOT NULL,
71+
PRIMARY KEY ("id"),
72+
CONSTRAINT "fk_digger_locks_organization" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
73+
);
74+
75+
-- Create index "idx_digger_locked_resource" to table: "digger_locks"
76+
CREATE INDEX IF NOT EXISTS "idx_digger_locked_resource" ON "public"."digger_locks" ("resource");
77+
78+
-- Create index "idx_digger_locks_deleted_at" to table: "digger_locks"
79+
CREATE INDEX IF NOT EXISTS "idx_digger_locks_deleted_at" ON "public"."digger_locks" ("deleted_at");
80+
81+
-- Create "digger_run_stages" table
82+
CREATE TABLE IF NOT EXISTS "public"."digger_run_stages" (
83+
"id" uuid NOT NULL DEFAULT gen_random_uuid(),
84+
"created_at" timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP,
85+
"updated_at" timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP,
86+
"deleted_at" timestamptz,
87+
"batch_id" uuid NOT NULL,
88+
PRIMARY KEY ("id"),
89+
CONSTRAINT "fk_digger_run_stages_batch" FOREIGN KEY ("batch_id") REFERENCES "public"."digger_batches" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
90+
);
91+
92+
-- Create index "idx_digger_run_stages_deleted_at" to table: "digger_run_stages"
93+
CREATE INDEX IF NOT EXISTS "idx_digger_run_stages_deleted_at" ON "public"."digger_run_stages" ("deleted_at");
94+
95+
-- Create index "idx_digger_run_batch_id" to table: "digger_run_stages"
96+
CREATE INDEX IF NOT EXISTS "idx_digger_run_batch_id" ON "public"."digger_run_stages" ("batch_id");
97+
98+
-- Create "digger_runs" table
99+
CREATE TABLE IF NOT EXISTS "public"."digger_runs" (
100+
"id" uuid NOT NULL DEFAULT gen_random_uuid(),
101+
"created_at" timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP,
102+
"updated_at" timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP,
103+
"deleted_at" timestamptz,
104+
"triggertype" text NOT NULL,
105+
"pr_number" bigint,
106+
"status" text NOT NULL,
107+
"commit_id" text NOT NULL,
108+
"digger_config" text,
109+
"github_installation_id" bigint,
110+
"repo_id" bigserial NOT NULL,
111+
"run_type" text NOT NULL,
112+
"plan_stage_id" uuid,
113+
"apply_stage_id" uuid,
114+
"project_name" text,
115+
"is_approved" boolean,
116+
"approval_author" text,
117+
"approval_date" timestamptz,
118+
PRIMARY KEY ("id"),
119+
CONSTRAINT "fk_digger_runs_repo" FOREIGN KEY ("repo_id") REFERENCES "public"."repos" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION,
120+
CONSTRAINT "fk_digger_runs_plan_stage" FOREIGN KEY ("plan_stage_id") REFERENCES "public"."digger_run_stages" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION,
121+
CONSTRAINT "fk_digger_runs_apply_stage" FOREIGN KEY ("apply_stage_id") REFERENCES "public"."digger_run_stages" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
122+
);
123+
124+
-- Create index "idx_digger_runs_deleted_at" to table: "digger_runs"
125+
CREATE INDEX IF NOT EXISTS "idx_digger_runs_deleted_at" ON "public"."digger_runs" ("deleted_at");
126+
127+
-- Create "github_app_installation_links" table
128+
CREATE TABLE IF NOT EXISTS "public"."github_app_installation_links" (
129+
"id" uuid NOT NULL DEFAULT gen_random_uuid(),
130+
"created_at" timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP,
131+
"updated_at" timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP,
132+
"deleted_at" timestamptz,
133+
"github_installation_id" bigint NOT NULL,
134+
"organization_id" uuid NOT NULL,
135+
"status" smallint NOT NULL,
136+
PRIMARY KEY ("id"),
137+
CONSTRAINT "fk_github_app_installation_links_organization" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION
138+
);
139+
140+
-- Create index "idx_github_app_installation_links_deleted_at" to table: "github_app_installation_links"
141+
CREATE INDEX IF NOT EXISTS "idx_github_app_installation_links_deleted_at" ON "public"."github_app_installation_links" ("deleted_at");
142+
143+
-- Create index "idx_github_installation_org" to table: "github_app_installation_links"
144+
CREATE INDEX IF NOT EXISTS "idx_github_installation_org" ON "public"."github_app_installation_links" ("github_installation_id", "organization_id");
145+
146+
-- Create "github_app_installations" table
147+
CREATE TABLE IF NOT EXISTS "public"."github_app_installations" (
148+
"id" uuid NOT NULL DEFAULT gen_random_uuid(),
149+
"created_at" timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP,
150+
"updated_at" timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP,
151+
"deleted_at" timestamptz,
152+
"github_installation_id" bigint NOT NULL,
153+
"github_app_id" bigint NOT NULL,
154+
"account_id" bigint NOT NULL,
155+
"login" text NOT NULL,
156+
"repo" text,
157+
"status" bigint NOT NULL,
158+
PRIMARY KEY ("id")
159+
);
160+
161+
-- Create index "idx_github_app_installations_deleted_at" to table: "github_app_installations"
162+
CREATE INDEX IF NOT EXISTS "idx_github_app_installations_deleted_at" ON "public"."github_app_installations" ("deleted_at");
163+
164+
-- Create "github_apps" table
165+
CREATE TABLE IF NOT EXISTS "public"."github_apps" (
166+
"id" uuid NOT NULL DEFAULT gen_random_uuid(),
167+
"created_at" timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP,
168+
"updated_at" timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP,
169+
"deleted_at" timestamptz,
170+
"github_id" bigint NOT NULL,
171+
"name" text NOT NULL,
172+
"github_app_url" text NOT NULL,
173+
PRIMARY KEY ("id")
174+
);
175+
176+
-- Create index "idx_github_apps_deleted_at" to table: "github_apps"
177+
CREATE INDEX IF NOT EXISTS "idx_github_apps_deleted_at" ON "public"."github_apps" ("deleted_at");

0 commit comments

Comments
 (0)