Merge ~pappacena/launchpad:db-patch-ociproject-project-pillar into launchpad:db-devel
Proposed by
Thiago F. Pappacena
Status: | Merged |
---|---|
Approved by: | Thiago F. Pappacena |
Approved revision: | 714e39f042625aaa3e914efe1acae14063a1882b |
Merge reported by: | Otto Co-Pilot |
Merged at revision: | not available |
Proposed branch: | ~pappacena/launchpad:db-patch-ociproject-project-pillar |
Merge into: | launchpad:db-devel |
Diff against target: |
52 lines (+46/-0) 1 file modified
database/schema/patch-2210-08-8.sql (+46/-0) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Colin Watson (community) | Approve | ||
Review via email: mp+383819@code.launchpad.net |
This proposal supersedes a proposal from 2020-05-12.
Commit message
Adding OCIProject.product database column and adjusting the way GitRepository table references OCIProject.
To post a comment you must log in.
I would move this patch to 2210-08-8; it might as well be part of the overall OCI series, as long as we haven't yet reached 9 and had to overflow to another minor number.
There are several other things we need to add:
* Rename OCIProject.product to OCIProject.project. While we still use the term "product" in anything old (partly because there's a lot of code to change, and partly because renaming DB columns/tables is awkward), everything new uses the term "project" instead. Compare GitRepository. project.
* Add something like this to the `ALTER TABLE OCIProject` statement so that it's actually possible to create an OCIProject row based on a project:
ALTER COLUMN distribution DROP NOT NULL,
ADD CONSTRAINT one_container CHECK ((project IS NULL) != (distribution IS NULL))
* Add a unique index on `OCIProject (project, ociprojectname) WHERE project IS NOT NULL`.
* Change the GitRepository one_container constraint to allow `(project IS NOT NULL AND distribution IS NULL AND sourcepackagename IS NULL AND ociprojectname IS NOT NULL)`.
* Alter most of the GitRepository project indexes involving (project) and (owner, project) to add a `WHERE ociprojectname IS NULL` condition, and add parallel indexes for the `ociprojectname IS NOT NULL` case. This is similar to 2210-08-1 and 2210-08-2, which between them do a similar sort of operation to add (distribution, ociprojectname) alongside (distribution, sourcepackagename).
* Note that there are complexities here because creating indexes on non-trivial tables is generally too slow to be done during a fastdowntime deployment. You'll need the same kind of structure that you see in 2210-08-1 and 2210-08-2: the initial cold patch should rename the relevant existing indexes to add an `old__` prefix; the follow-up hot patch should create new indexes and drop the old ones. These must not be in the same MP; the hot patch should be proposed against master from a branch that doesn't include the cold patch. We'll need to apply the hot patch manually to production with `CONCURRENTLY` shortly after the fastdowntime, and sync up master later.