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

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 8be90ed9b35b298f958cc8dcb4f4b8ea715809bb
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: 68 lines (+44/-0)
2 files modified
database/schema/patch-2210-36-0.sql (+42/-0)
database/schema/security.cfg (+2/-0)
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+409753@code.launchpad.net

Commit message

Merge db-stable 8be90ed9b3 (Add AccessToken table)

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-36-0.sql b/database/schema/patch-2210-36-0.sql
2new file mode 100644
3index 0000000..daa41fc
4--- /dev/null
5+++ b/database/schema/patch-2210-36-0.sql
6@@ -0,0 +1,42 @@
7+-- Copyright 2021 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 AccessToken (
13+ id serial PRIMARY KEY,
14+ date_created timestamp without time zone DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
15+ token_sha256 text NOT NULL,
16+ owner integer NOT NULL REFERENCES person,
17+ description text NOT NULL,
18+ git_repository integer REFERENCES gitrepository NOT NULL,
19+ scopes jsonb NOT NULL,
20+ date_last_used timestamp without time zone,
21+ date_expires timestamp without time zone,
22+ revoked_by integer REFERENCES person
23+);
24+
25+COMMENT ON TABLE AccessToken IS 'A personal access token for the webservice API.';
26+COMMENT ON COLUMN AccessToken.date_created IS 'When the token was created.';
27+COMMENT ON COLUMN AccessToken.token_sha256 IS 'SHA-256 hash of the secret token.';
28+COMMENT ON COLUMN AccessToken.owner IS 'The person who created the token.';
29+COMMENT ON COLUMN AccessToken.description IS 'A short description of the token''s purpose.';
30+COMMENT ON COLUMN AccessToken.git_repository IS 'The Git repository for which the token was issued.';
31+COMMENT ON COLUMN AccessToken.scopes IS 'A list of scopes granted by the token.';
32+COMMENT ON COLUMN AccessToken.date_last_used IS 'When the token was last used.';
33+COMMENT ON COLUMN AccessToken.date_expires IS 'When the token should expire or was revoked.';
34+COMMENT ON COLUMN AccessToken.revoked_by IS 'The person who revoked the token, if any.';
35+
36+CREATE UNIQUE INDEX accesstoken__token_sha256__key
37+ ON AccessToken (token_sha256);
38+CREATE INDEX accesstoken__owner__idx
39+ ON AccessToken (owner);
40+CREATE INDEX accesstoken__git_repository__idx
41+ ON AccessToken (git_repository);
42+CREATE INDEX accesstoken__date_expires__idx
43+ ON AccessToken (date_expires)
44+ WHERE date_expires IS NOT NULL;
45+CREATE INDEX accesstoken__revoked_by__idx
46+ ON AccessToken (revoked_by);
47+
48+INSERT INTO LaunchpadDatabaseRevision VALUES (2210, 36, 0);
49diff --git a/database/schema/security.cfg b/database/schema/security.cfg
50index f664a4a..39822d1 100644
51--- a/database/schema/security.cfg
52+++ b/database/schema/security.cfg
53@@ -116,6 +116,7 @@ public.accesspolicy = SELECT, INSERT, UPDATE, DELETE
54 public.accesspolicyartifact = SELECT, INSERT, UPDATE, DELETE
55 public.accesspolicygrant = SELECT, INSERT, UPDATE, DELETE
56 public.accesspolicygrantflat = SELECT
57+public.accesstoken = SELECT, INSERT, UPDATE, DELETE
58 public.account = SELECT, INSERT, UPDATE, DELETE
59 public.announcement = SELECT, INSERT, UPDATE, DELETE
60 public.answercontact = SELECT, INSERT, UPDATE, DELETE
61@@ -2298,6 +2299,7 @@ public.accesspolicyartifact = SELECT
62 public.accessartifactgrant = SELECT, UPDATE, DELETE
63 public.accesspolicy = SELECT, UPDATE, DELETE
64 public.accesspolicygrant = SELECT, UPDATE, DELETE
65+public.accesstoken = SELECT, UPDATE
66 public.account = SELECT, UPDATE
67 public.announcement = SELECT, UPDATE
68 public.answercontact = SELECT, UPDATE, DELETE

Subscribers

People subscribed via source and target branches

to status/vote changes: