Merge ~cjwatson/launchpad:merge-db-stable into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 2c03044a985787cf744348c44bc3af2e25ccc3f0
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:merge-db-stable
Merge into: launchpad:master
Diff against target: 123 lines (+69/-0)
3 files modified
database/schema/patch-2210-08-6.sql (+38/-0)
database/schema/patch-2210-08-7.sql (+22/-0)
database/schema/security.cfg (+9/-0)
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+381437@code.launchpad.net

Commit message

Merge db-stable 2c03044a98 (Add OCIRegistryCredentials, OCIPushRule, and OCIRecipeBuildJob tables)

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) wrote :

Deployed to the production database today.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/database/schema/patch-2210-08-6.sql b/database/schema/patch-2210-08-6.sql
2new file mode 100644
3index 0000000..62c5d55
4--- /dev/null
5+++ b/database/schema/patch-2210-08-6.sql
6@@ -0,0 +1,38 @@
7+-- Copyright 2019 Canonical Ltd. This software is licensed under the
8+-- GNU Affero General Public License version 3 (see the file LICENSE).
9+
10+SET client_min_messages=ERROR;
11+
12+CREATE TABLE OCIRegistryCredentials (
13+ id serial PRIMARY KEY,
14+ owner integer NOT NULL REFERENCES Person,
15+ url text NOT NULL,
16+ credentials jsonb NOT NULL
17+);
18+
19+CREATE INDEX ociregistrycredentials__owner__idx
20+ ON OCIRegistryCredentials (owner);
21+
22+COMMENT ON TABLE OCIRegistryCredentials IS 'Credentials for pushing to an OCI registry.';
23+COMMENT ON COLUMN OCIRegistryCredentials.owner IS 'The owner of these credentials. Only the owner is entitled to create push rules using them.';
24+COMMENT ON COLUMN OCIRegistryCredentials.url IS 'The registry URL.';
25+COMMENT ON COLUMN OCIRegistryCredentials.credentials IS 'Encrypted credentials for pushing to the registry.';
26+
27+CREATE TABLE OCIPushRule (
28+ id serial PRIMARY KEY,
29+ recipe integer NOT NULL REFERENCES OCIRecipe,
30+ registry_credentials integer NOT NULL REFERENCES OCIRegistryCredentials,
31+ image_name text NOT NULL
32+);
33+
34+CREATE UNIQUE INDEX ocipushrule__recipe__registry_credentials__image_name__key
35+ ON OCIPushRule (recipe, registry_credentials, image_name);
36+CREATE INDEX ocipushrule__registry_credentials__idx
37+ ON OCIPushRule (registry_credentials);
38+
39+COMMENT ON TABLE OCIPushRule IS 'A rule for pushing builds of an OCI recipe to a registry.';
40+COMMENT ON COLUMN OCIPushRule.recipe IS 'The recipe for which the rule is defined.';
41+COMMENT ON COLUMN OCIPushRule.registry_credentials IS 'The registry credentials to use.';
42+COMMENT ON COLUMN OCIPushRule.image_name IS 'The intended name of the image on the registry.';
43+
44+INSERT INTO LaunchpadDatabaseRevision VALUES (2210, 08, 6);
45diff --git a/database/schema/patch-2210-08-7.sql b/database/schema/patch-2210-08-7.sql
46new file mode 100644
47index 0000000..47ea635
48--- /dev/null
49+++ b/database/schema/patch-2210-08-7.sql
50@@ -0,0 +1,22 @@
51+-- Copyright 2020 Canonical Ltd. This software is licensed under the
52+-- GNU Affero General Public License version 3 (see the file LICENSE).
53+
54+CREATE TABLE OCIRecipeBuildJob (
55+ job integer PRIMARY KEY REFERENCES Job ON DELETE CASCADE NOT NULL,
56+ build integer REFERENCES ocirecipebuild NOT NULL,
57+ job_type integer NOT NULL,
58+ json_data jsonb NOT NULL
59+);
60+
61+COMMENT ON TABLE OCIRecipeBuildJob IS 'Contains references to jobs that are executed for a build of an OCI recipe.';
62+COMMENT ON COLUMN OCIRecipeBuildJob.job IS 'A reference to a Job row that has all the common job details.';
63+COMMENT ON COLUMN OCIRecipeBuildJob.build IS 'The OCI recipe build that this job is for.';
64+COMMENT ON COLUMN OCIRecipeBuildJob.job_type IS 'The type of a job, such as a registry push.';
65+COMMENT ON COLUMN OCIRecipeBuildJob.json_data IS 'Data that is specific to a particular job type.';
66+
67+CREATE INDEX ocirecipebuildjob__build__job_type__job__idx
68+ ON OCIRecipeBuildJob (build, job_type, job);
69+CREATE INDEX ocirecipebuildjob__job__job_type__idx
70+ ON OCIRecipeBuildJob (job, job_type);
71+
72+INSERT INTO LaunchpadDatabaseRevision VALUES (2210, 08, 7);
73diff --git a/database/schema/security.cfg b/database/schema/security.cfg
74index 4c1b396..f5cca8d 100644
75--- a/database/schema/security.cfg
76+++ b/database/schema/security.cfg
77@@ -245,9 +245,12 @@ public.ocifile = SELECT, INSERT, UPDATE, DELETE
78 public.ociproject = SELECT, INSERT, UPDATE, DELETE
79 public.ociprojectname = SELECT, INSERT, UPDATE
80 public.ociprojectseries = SELECT, INSERT, UPDATE, DELETE
81+public.ocipushrule = SELECT, INSERT, UPDATE, DELETE
82 public.ocirecipe = SELECT, INSERT, UPDATE, DELETE
83 public.ocirecipearch = SELECT, INSERT, DELETE
84 public.ocirecipebuild = SELECT, INSERT, UPDATE, DELETE
85+public.ocirecipebuildjob = SELECT, INSERT, UPDATE, DELETE
86+public.ociregistrycredentials = SELECT, INSERT, UPDATE, DELETE
87 public.officialbugtag = SELECT, INSERT, UPDATE, DELETE
88 public.openidconsumerassociation = SELECT, INSERT, UPDATE, DELETE
89 public.openidconsumernonce = SELECT, INSERT, UPDATE
90@@ -998,6 +1001,7 @@ public.ociproject = SELECT
91 public.ociprojectname = SELECT
92 public.ocirecipe = SELECT
93 public.ocirecipebuild = SELECT, UPDATE
94+public.ocirecipebuildjob = SELECT, INSERT
95 public.openididentifier = SELECT
96 public.packageset = SELECT
97 public.packagesetgroup = SELECT
98@@ -1431,6 +1435,9 @@ public.milestonetag = SELECT
99 public.ociproject = SELECT
100 public.ociprojectname = SELECT
101 public.ociprojectseries = SELECT
102+public.ocirecipe = SELECT, UPDATE
103+public.ocirecipebuild = SELECT, UPDATE
104+public.ocirecipebuildjob = SELECT, INSERT, UPDATE
105 public.openididentifier = SELECT
106 public.packagecopyjob = SELECT, INSERT
107 public.packagediff = SELECT, INSERT, UPDATE, DELETE
108@@ -2302,6 +2309,7 @@ public.ociproject = SELECT, UPDATE
109 public.ociprojectseries = SELECT, UPDATE
110 public.ocirecipe = SELECT, UPDATE
111 public.ocirecipebuild = SELECT, UPDATE
112+public.ociregistrycredentials = SELECT, UPDATE
113 public.officialbugtag = SELECT
114 public.openididentifier = SELECT, UPDATE
115 public.packagecopyrequest = SELECT, UPDATE
116@@ -2424,6 +2432,7 @@ public.ociproject = SELECT
117 public.ociprojectseries = SELECT
118 public.ocirecipe = SELECT
119 public.ocirecipebuild = SELECT
120+public.ociregistrycredentials = SELECT
121 public.openidconsumerassociation = SELECT, DELETE
122 public.openidconsumernonce = SELECT, DELETE
123 public.packageuploadlog = SELECT

Subscribers

People subscribed via source and target branches

to status/vote changes: