Merge lp:~linaro-infrastructure/launchpad/workitems-schema-changes into lp:launchpad/db-devel
- workitems-schema-changes
- Merge into db-devel
Status: | Superseded |
---|---|
Proposed branch: | lp:~linaro-infrastructure/launchpad/workitems-schema-changes |
Merge into: | lp:launchpad/db-devel |
Diff against target: |
143 lines (+113/-0) 3 files modified
database/schema/comments.sql (+30/-0) database/schema/patch-2209-06-1.sql (+73/-0) database/schema/security.cfg (+10/-0) |
To merge this branch: | bzr merge lp:~linaro-infrastructure/launchpad/workitems-schema-changes |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Stuart Bishop (community) | db | Approve | |
Robert Collins | db | Pending | |
Launchpad code reviewers | Pending | ||
Review via email: mp+91295@code.launchpad.net |
This proposal has been superseded by a proposal from 2012-02-06.
Commit message
Description of the change
Hi,
This branch adds the schema required for making Work Items first class database objects.
The topic has been discussed here https:/
Thanks,
Mattias
Guilherme Salgado (salgado) wrote : | # |
Guilherme Salgado (salgado) wrote : | # |
I obviously meant lp:~linaro-infrastructure/launchpad/workitems-migration-script above
Stuart Bishop (stub) wrote : | # |
Mostly fine.
Do we need a 'name' column on SpecificationWo
Please rename the 'date' column on SpecificationWo
I don't really like the 'day' column name on SpecificationWo
We need some indexes:
-- Foreign key, selecting by specification and sorting by date_created.
CREATE INDEX specificationwo
ON SpecificationWo
-- Foreign key.
CREATE INDEX specificationwo
ON SpecificationWo
-- Foreign key, required for person merge.
CREATE INDEX specificationwo
ON SpecificationWo
-- Foreign key, selecting by work_item and ordering by date_created
CREATE INDEX specificationwo
ON SpecificationWo
-- Foreign key.
CREATE INDEX specificationwo
ON SpecificationWo
WHERE new_milestone IS NOT NULL;
-- Foreign key, required for person merge.
CREATE INDEX specificationwo
ON SpecificationWo
-- Foreign key, and selection by date.
CREATE INDEX specificationwo
ON SpecificationWo
-- Foreign key, required for person merge.
CREATE INDEX specificationwo
ON SpecificationWo
-- Foreign key.
CREATE INDEX specificationwo
ON SpecificationWo
Stuart Bishop (stub) wrote : | # |
wgrant mentioned that you might want a 'sequence' column to allow you to maintain display or implementation order of work items. If you do, please add it and resubmit the proposal.
Mattias Backman (mabac) wrote : | # |
On Sun, Feb 5, 2012 at 9:50 PM, Stuart Bishop
<email address hidden> wrote:
> Review: Approve db
>
> Mostly fine.
Good to hear. Thanks.
>
> Do we need a 'name' column on SpecificationWo
I don't think we really need it, at least not for the user end of
things. We wouldn't pass around url:s to work items as we do with bugs
for instance, we'd link to the specification instead to reach the
complete set of work items for that specification.
We could add a name column, but it should be automatically generated
so the user would not have to enter a name for each work item. That
would just add overhead to something that's supposed to be really
light weight. Could we start out with just using the internal id for
API calls and maybe add a namn column later if we need it?
>
> Please rename the 'date' column on SpecificationWo
Absolutely, will do.
>
> I don't really like the 'day' column name on SpecificationWo
How about day_harvested or something like that?
>
> We need some indexes:
>
> -- Foreign key, selecting by specification and sorting by date_created.
> CREATE INDEX specificationwo
> ON SpecificationWo
>
> -- Foreign key.
> CREATE INDEX specificationwo
> ON SpecificationWo
>
> -- Foreign key, required for person merge.
> CREATE INDEX specificationwo
> ON SpecificationWo
>
>
> -- Foreign key, selecting by work_item and ordering by date_created
> CREATE INDEX specificationwo
> ON SpecificationWo
>
> -- Foreign key.
> CREATE INDEX specificationwo
> ON SpecificationWo
> WHERE new_milestone IS NOT NULL;
>
> -- Foreign key, required for person merge.
> CREATE INDEX specificationwo
> ON SpecificationWo
>
> -- Foreign key, and selection by date.
> CREATE INDEX specificationwo
> ON SpecificationWo
>
> -- Foreign key, required for person merge.
> CREATE INDEX specificationwo
> ON SpecificationWo
>
> -- Foreign key.
> CREATE INDEX specificationwo
> ON SpecificationWo
So we'll add that to the patch then.
> --
> https:/
> Your team Linaro Infrastructure is subscribed to branch lp:~linaro-infrastructure/launchpad/workitems-schema-changes.
Mattias Backman (mabac) wrote : | # |
On Sun, Feb 5, 2012 at 11:19 PM, Stuart Bishop
<email address hidden> wrote:
> wgrant mentioned that you might want a 'sequence' column to allow you to maintain display or implementation order of work items. If you do, please add it and resubmit the proposal.
I'm not sure I understand I understand the use for a sequence column.
If it's just for maintaining display order we can use the id column.
> --
> https:/
> Your team Linaro Infrastructure is subscribed to branch lp:~linaro-infrastructure/launchpad/workitems-schema-changes.
Robert Collins (lifeless) wrote : | # |
On Tue, Feb 7, 2012 at 8:34 AM, Mattias Backman
<email address hidden> wrote:
> I'm not sure I understand I understand the use for a sequence column.
> If it's just for maintaining display order we can use the id column.
in the presence of deletes and adds the id column won't match your UI,
unless your UI only allows adds at the bottom of the list.
Mattias Backman (mabac) wrote : | # |
On Mon, Feb 6, 2012 at 11:47 AM, Robert Collins
<email address hidden> wrote:
> On Tue, Feb 7, 2012 at 8:34 AM, Mattias Backman
> <email address hidden> wrote:
>> I'm not sure I understand I understand the use for a sequence column.
>> If it's just for maintaining display order we can use the id column.
>
> in the presence of deletes and adds the id column won't match your UI,
> unless your UI only allows adds at the bottom of the list.
Ah you're right, we will want to preserve the order of the work items.
So we need a sequence column.
>
> --
> https:/
> Your team Linaro Infrastructure is subscribed to branch lp:~linaro-infrastructure/launchpad/workitems-schema-changes.
Preview Diff
1 | === modified file 'database/schema/comments.sql' |
2 | --- database/schema/comments.sql 2012-01-25 06:02:40 +0000 |
3 | +++ database/schema/comments.sql 2012-02-06 23:47:23 +0000 |
4 | @@ -899,6 +899,36 @@ |
5 | COMMENT ON COLUMN RevisionCache.sourcepackagename IS 'The sourcepackagename for which a source package branch contains the revision.'; |
6 | COMMENT ON COLUMN RevisionCache.private IS 'True if the revision is only found in private branches, False if it can be found in a non-private branch.'; |
7 | |
8 | +-- specificationworkitem |
9 | +COMMENT ON TABLE specificationworkitem IS 'A work item which is a piece of work relating to a blueprint.'; |
10 | +COMMENT ON COLUMN specificationworkitem.id IS 'The id of the work item.'; |
11 | +COMMENT ON COLUMN specificationworkitem.title IS 'The title of the work item.'; |
12 | +COMMENT ON COLUMN specificationworkitem.specification IS 'The blueprint that this work item is a part of.'; |
13 | +COMMENT ON COLUMN specificationworkitem.assignee IS 'The person who is assigned to complete the work item.'; |
14 | +COMMENT ON COLUMN specificationworkitem.milestone IS 'The milestone this work item is targetted to.'; |
15 | +COMMENT ON COLUMN specificationworkitem.date_created IS 'The date on which the work item was created.'; |
16 | +COMMENT ON COLUMN specificationworkitem.sequence IS 'The sequence number specifies the order of work items in the UI.'; |
17 | +COMMENT ON COLUMN specificationworkitem.deleted IS 'Marks if the work item has been deleted. To be able to keep history we do not want to actually delete them from the database.'; |
18 | + |
19 | +-- specificationworkitemchange |
20 | +COMMENT ON TABLE specificationworkitemchange IS 'A property change on a work item.'; |
21 | +COMMENT ON COLUMN specificationworkitemchange.id IS 'Id of the change.'; |
22 | +COMMENT ON COLUMN specificationworkitemchange.work_item IS 'The work item for which a propery has changed.'; |
23 | +COMMENT ON COLUMN specificationworkitemchange.new_status IS 'The new status for the work item.'; |
24 | +COMMENT ON COLUMN specificationworkitemchange.new_milestone IS 'The new milestone the work item has been targetted to.'; |
25 | +COMMENT ON COLUMN specificationworkitemchange.new_assignee IS 'The person which the work item has be assigned to.'; |
26 | +COMMENT ON COLUMN specificationworkitemchange.date_created IS 'The time of the change.'; |
27 | + |
28 | +-- specificationworkitemstats |
29 | +COMMENT ON TABLE specificationworkitemstats IS 'Stats for work items that are collected by a scheduled script.'; |
30 | +COMMENT ON COLUMN specificationworkitemstats.id IS 'The id for this stats collection.'; |
31 | +COMMENT ON COLUMN specificationworkitemstats.specification IS 'The related blueprint.'; |
32 | +COMMENT ON COLUMN specificationworkitemstats.day IS 'Day when the stats where collected.'; |
33 | +COMMENT ON COLUMN specificationworkitemstats.status IS 'The work item status that work items are counted for.'; |
34 | +COMMENT ON COLUMN specificationworkitemstats.assignee IS 'The assignee that work items are counted for.'; |
35 | +COMMENT ON COLUMN specificationworkitemstats.milestone IS 'The milestone that work items are counted for.'; |
36 | +COMMENT ON COLUMN specificationworkitemstats.count IS 'The number of work items for the blueprint with the particular status, assignee and milestone.'; |
37 | + |
38 | -- Sprint |
39 | COMMENT ON TABLE Sprint IS 'A meeting, sprint or conference. This is a convenient way to keep track of a collection of specs that will be discussed, and the people that will be attending.'; |
40 | COMMENT ON COLUMN Sprint.driver IS 'The driver (together with the registrant or owner) is responsible for deciding which topics will be accepted onto the agenda of the sprint.'; |
41 | |
42 | === added file 'database/schema/patch-2209-06-1.sql' |
43 | --- database/schema/patch-2209-06-1.sql 1970-01-01 00:00:00 +0000 |
44 | +++ database/schema/patch-2209-06-1.sql 2012-02-06 23:47:23 +0000 |
45 | @@ -0,0 +1,73 @@ |
46 | +-- Copyright 2012 Canonical Ltd. This software is licensed under the |
47 | +-- GNU Affero General Public License version 3 (see the file LICENSE). |
48 | + |
49 | +SET client_min_messages=ERROR; |
50 | + |
51 | +CREATE TABLE specificationworkitem ( |
52 | + id SERIAL PRIMARY KEY, |
53 | + title text NOT NULL, |
54 | + specification integer NOT NULL REFERENCES specification, |
55 | + assignee integer REFERENCES person, |
56 | + milestone integer REFERENCES milestone, |
57 | + date_created timestamp without time zone DEFAULT |
58 | + timezone('UTC'::text, now()) NOT NULL, |
59 | + status integer NOT NULL, |
60 | + sequence integer NOT NULL, |
61 | + deleted boolean NOT NULL DEFAULT FALSE); |
62 | + |
63 | +CREATE TABLE specificationworkitemchange ( |
64 | + id SERIAL PRIMARY KEY, |
65 | + work_item integer NOT NULL REFERENCES specificationworkitem, |
66 | + new_status integer NOT NULL, |
67 | + new_milestone integer REFERENCES milestone, |
68 | + new_assignee integer REFERENCES person, |
69 | + date_created timestamp without time zone DEFAULT |
70 | + timezone('UTC'::text, now()) NOT NULL); |
71 | + |
72 | +CREATE TABLE specificationworkitemstats ( |
73 | + id SERIAL PRIMARY KEY, |
74 | + specification integer REFERENCES specification, |
75 | + day date NOT NULL, |
76 | + status integer NOT NULL, |
77 | + assignee integer REFERENCES person, |
78 | + milestone integer REFERENCES milestone, |
79 | + count integer NOT NULL); |
80 | + |
81 | +-- Foreign key, selecting by specification and sorting by date_created. |
82 | +CREATE INDEX specificationworkitem__specification__date_created__idx |
83 | + ON SpecificationWorkItem(specification, date_created); |
84 | + |
85 | +-- Foreign key. |
86 | +CREATE INDEX specificationworkitem__milestone__idx |
87 | + ON SpecificationWorkItem(milestone); |
88 | + |
89 | +-- Foreign key, required for person merge. |
90 | +CREATE INDEX specificationworkitem__assignee__idx |
91 | + ON SpecificationWorkItem(assignee) WHERE assignee IS NOT NULL; |
92 | + |
93 | +-- Foreign key, selecting by work_item and ordering by date_created |
94 | +CREATE INDEX specificationworkitemchange__work_item__date_created__idx |
95 | + ON SpecificationWorkItemChange(work_item, date_created); |
96 | + |
97 | +-- Foreign key. |
98 | +CREATE INDEX specificationworkitemchange__new_milestone__idx |
99 | + ON SpecificationWorkItemChange(new_milestone) |
100 | + WHERE new_milestone IS NOT NULL; |
101 | + |
102 | +-- Foreign key, required for person merge. |
103 | +CREATE INDEX specificationworkitemchange__new_assignee__idx |
104 | + ON SpecificationWorkItemChange(new_assignee) WHERE new_assignee IS NOT NULL; |
105 | + |
106 | +-- Foreign key, and selection by date. |
107 | +CREATE INDEX specificationworkitemstats_specification__day__idx |
108 | + ON SpecificationWorkItemStats(specification, day); |
109 | + |
110 | +-- Foreign key, required for person merge. |
111 | +CREATE INDEX specificationworkitemstats__assignee__idx |
112 | + ON SpecificationWorkItemStats(assignee) WHERE assignee IS NOT NULL; |
113 | + |
114 | +-- Foreign key. |
115 | +CREATE INDEX specificationworkitemstats__milestone__idx |
116 | + ON SpecificationWorkItemStats(milestone) WHERE milestone IS NOT NULL; |
117 | + |
118 | +INSERT INTO LaunchpadDatabaseRevision VALUES (2209, 06, 1); |
119 | |
120 | === modified file 'database/schema/security.cfg' |
121 | --- database/schema/security.cfg 2012-02-01 14:30:51 +0000 |
122 | +++ database/schema/security.cfg 2012-02-06 23:47:23 +0000 |
123 | @@ -288,6 +288,9 @@ |
124 | public.specificationfeedback = SELECT, INSERT, UPDATE, DELETE |
125 | public.specificationmessage = SELECT, INSERT |
126 | public.specificationsubscription = SELECT, INSERT, UPDATE, DELETE |
127 | +public.specificationworkitem = SELECT, INSERT, UPDATE |
128 | +public.specificationworkitemchange = SELECT, INSERT, UPDATE |
129 | +public.specificationworkitemstats = SELECT |
130 | public.spokenin = SELECT, INSERT, DELETE |
131 | public.sprint = SELECT, INSERT, UPDATE |
132 | public.sprintattendance = SELECT, INSERT, UPDATE, DELETE |
133 | @@ -2298,3 +2301,10 @@ |
134 | groups=read |
135 | public.oauthnonce = SELECT |
136 | public.openidconsumernonce = SELECT |
137 | + |
138 | +[work_items_stats] |
139 | +type=user |
140 | +groups=script |
141 | +public.specificationworkitemstats = SELECT, INSERT |
142 | +public.specificationworkitem = SELECT |
143 | +public.specificationworkitemchange = SELECT |
We've also implemented the code to migrate work items from the whiteboard to the new table (lp:~linaro-infrastructure/launchpad/workitems-schema-changes), to make sure this is all we need.