Ines Almeida has proposed merging ~ines-almeida/launchpad:project-tokens/db-patch into launchpad:master.
Commit message: DB patch: Add project to access token table Requested reviews: Launchpad code reviewers (launchpad-reviewers) For more details, see: https://code.launchpad.net/~ines-almeida/launchpad/+git/launchpad/+merge/451470 -- Your team Launchpad code reviewers is requested to review the proposed merge of ~ines-almeida/launchpad:project-tokens/db-patch into launchpad:master.
diff --git a/database/schema/patch-2211-22-0.sql b/database/schema/patch-2211-22-0.sql new file mode 100644 index 0000000..411f0fe --- /dev/null +++ b/database/schema/patch-2211-22-0.sql @@ -0,0 +1,21 @@ +-- Copyright 2023 Canonical Ltd. This software is licensed under the +-- GNU Affero General Public License version 3 (see the file LICENSE). + +SET client_min_messages=ERROR; + +ALTER TABLE AccessToken + ADD COLUMN project integer REFERENCES product; + +COMMENT ON COLUMN AccessToken.project IS 'The project for which the token was issued.'; + +CREATE INDEX accesstoken__project__idx + ON AccessToken (project, id) WHERE project IS NOT NULL; + +-- There can only be either a git_repository or a project as target +ALTER TABLE AccessToken + ALTER COLUMN git_repository DROP NOT NULL, + ADD CONSTRAINT one_target CHECK ( + (public.null_count(ARRAY[git_repository, project]) = 1) + ); + +INSERT INTO LaunchpadDatabaseRevision VALUES (2211, 22, 0);
_______________________________________________ Mailing list: https://launchpad.net/~launchpad-reviewers Post to : [email protected] Unsubscribe : https://launchpad.net/~launchpad-reviewers More help : https://help.launchpad.net/ListHelp

