Merge lp:~james-w/launchpad/archive-job-db into lp:launchpad/db-devel

Proposed by James Westby
Status: Merged
Approved by: Stuart Bishop
Approved revision: no longer in the source branch.
Merged at revision: 9586
Proposed branch: lp:~james-w/launchpad/archive-job-db
Merge into: lp:launchpad/db-devel
Prerequisite: lp:~james-w/launchpad/test-package-cloner
Diff against target: 118 lines (+56/-0)
5 files modified
database/sampledata/current-dev.sql (+10/-0)
database/sampledata/current.sql (+10/-0)
database/schema/comments.sql (+8/-0)
database/schema/patch-2207-64-0.sql (+27/-0)
database/schema/security.cfg (+1/-0)
To merge this branch: bzr merge lp:~james-w/launchpad/archive-job-db
Reviewer Review Type Date Requested Status
Stuart Bishop (community) db Approve
Robert Collins db Pending
Björn Tillenius db Pending
Review via email: mp+28437@code.launchpad.net

Commit message

Add an ArchiveJob table.

Description of the change

Hi,

This adds an ArchiveJob, like BranchJob and BugJob.

The first use is for copy archive jobs, that currently aren't jobs
but should be. I expect there will be more uses in the future.

Thanks,

James

To post a comment you must log in.
Revision history for this message
James Westby (james-w) wrote :

You can see the model classes at

  https://code.edge.launchpad.net/~james-w/launchpad/copy-archive-job/+merge/28439

with some more description of the aim of this job type.

Thanks,

James

Revision history for this message
Stuart Bishop (stub) wrote :

Generally fine.

patch-2207-64-0.sql

I think the job foreign key constraint should be ON DELETE CASCADE to make job garbage collection a little easier:

job integer NOT NULL CONSTRAINT archivejob__job__fk REFERENCES job ON DELETE CASCADE

(the archive foriegn key constraint should not be).

Revision history for this message
Stuart Bishop (stub) :
review: Approve (db)
Revision history for this message
Stuart Bishop (stub) wrote :

Oh... please fix the security.cfg declarations. The [write] section is deprecated per the comments. Please add explicit permissions to users.

Revision history for this message
James Westby (james-w) wrote :

On Fri, 25 Jun 2010 07:41:28 -0000, Stuart Bishop <email address hidden> wrote:
> Oh... please fix the security.cfg declarations. The [write] section is deprecated per the comments. Please add explicit permissions to users.

I was just cargo-culting, so I'm not surprised it is wrong.

I guess the other permission is ok?

I don't know what explicit permissions other than that would be needed.

Currently these jobs would be added by a script run by an admin on
request, and then we will add a cronscript to process them. If you can
tell me what users/permission might be needed for that then I can add
them now, otherwise I will just leave the default in and work with the
Soyuz team on making other changes needed once we have something to test
on dogfood.

Thanks,

James

Revision history for this message
Stuart Bishop (stub) wrote :

No problems - the permissions can be added when the cronscript or whatever processes the jobs is written.

Revision history for this message
James Westby (james-w) wrote :

Hi Stuart,

Could you give this another look over as I have made the changes you suggested?

Thanks,

James

Revision history for this message
Stuart Bishop (stub) wrote :

Looks good

review: Approve (db)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'database/sampledata/current-dev.sql'
2--- database/sampledata/current-dev.sql 2010-07-28 14:36:32 +0000
3+++ database/sampledata/current-dev.sql 2010-07-28 17:45:50 +0000
4@@ -791,6 +791,9 @@
5
6
7
8+
9+
10+
11 SET SESSION AUTHORIZATION DEFAULT;
12
13 ALTER TABLE account DISABLE TRIGGER ALL;
14@@ -2207,6 +2210,13 @@
15 ALTER TABLE archivedependency ENABLE TRIGGER ALL;
16
17
18+ALTER TABLE archivejob DISABLE TRIGGER ALL;
19+
20+
21+
22+ALTER TABLE archivejob ENABLE TRIGGER ALL;
23+
24+
25 ALTER TABLE packagesetgroup DISABLE TRIGGER ALL;
26
27
28
29=== modified file 'database/sampledata/current.sql'
30--- database/sampledata/current.sql 2010-07-28 14:36:32 +0000
31+++ database/sampledata/current.sql 2010-07-28 17:45:50 +0000
32@@ -791,6 +791,9 @@
33
34
35
36+
37+
38+
39 SET SESSION AUTHORIZATION DEFAULT;
40
41 ALTER TABLE account DISABLE TRIGGER ALL;
42@@ -2164,6 +2167,13 @@
43 ALTER TABLE archivedependency ENABLE TRIGGER ALL;
44
45
46+ALTER TABLE archivejob DISABLE TRIGGER ALL;
47+
48+
49+
50+ALTER TABLE archivejob ENABLE TRIGGER ALL;
51+
52+
53 ALTER TABLE packagesetgroup DISABLE TRIGGER ALL;
54
55
56
57=== modified file 'database/schema/comments.sql'
58--- database/schema/comments.sql 2010-07-23 19:47:16 +0000
59+++ database/schema/comments.sql 2010-07-28 17:45:50 +0000
60@@ -29,6 +29,14 @@
61 COMMENT ON COLUMN ApportJob.job_type IS 'The type of job (enumeration value). Allows us to query the database for a given subset of ApportJobs.';
62 COMMENT ON COLUMN ApportJob.json_data IS 'A JSON struct containing data for the job.';
63
64+-- ArchiveJob
65+
66+COMMENT ON TABLE ArchiveJob is 'Contains references to jobs to be run against Archives.';
67+COMMENT ON COLUMN ArchiveJob.archive IS 'The archive on which the job is to be run.';
68+COMMENT ON COLUMN ArchiveJob.job_type IS 'The type of job (enumeration value). Allows us to query the database for a given subset of ArchiveJobs.';
69+COMMENT ON COLUMN ArchiveJob.json_data IS 'A JSON struct containing data for the job.';
70+
71+
72 -- Branch
73 COMMENT ON TABLE Branch IS 'Bzr branch';
74 COMMENT ON COLUMN Branch.registrant IS 'The user that registered the branch.';
75
76=== added file 'database/schema/patch-2207-64-0.sql'
77--- database/schema/patch-2207-64-0.sql 1970-01-01 00:00:00 +0000
78+++ database/schema/patch-2207-64-0.sql 2010-07-28 17:45:50 +0000
79@@ -0,0 +1,27 @@
80+-- Copyright 2009 Canonical Ltd. This software is licensed under the
81+-- GNU Affero General Public License version 3 (see the file LICENSE).
82+
83+SET client_min_messages=ERROR;
84+
85+-- The schema patch required for adding archive jobs, the first being
86+-- creation of copy archives.
87+
88+-- The `ArchiveJob` table captures the data required for an archive job.
89+
90+CREATE TABLE ArchiveJob (
91+ id serial PRIMARY KEY,
92+ -- FK to the `Job` record with the "generic" data about this archive
93+ -- job.
94+ job integer NOT NULL CONSTRAINT archivejob__job__fk REFERENCES job ON DELETE CASCADE,
95+ -- FK to the associated `Archive` record.
96+ archive integer NOT NULL CONSTRAINT archivejob__archive__fk REFERENCES archive,
97+ -- The particular type of archive job
98+ job_type integer NOT NULL,
99+ -- JSON data for use by the job
100+ json_data text
101+);
102+
103+ALTER TABLE ArchiveJob ADD CONSTRAINT archivejob__job__key UNIQUE (job);
104+CREATE INDEX archivejob__archive__job_type__idx ON ArchiveJob(archive, job_type);
105+
106+INSERT INTO LaunchpadDatabaseRevision VALUES (2207, 64, 0);
107
108=== modified file 'database/schema/security.cfg'
109--- database/schema/security.cfg 2010-07-28 14:36:32 +0000
110+++ database/schema/security.cfg 2010-07-28 17:45:50 +0000
111@@ -82,6 +82,7 @@
112 public.apportjob = SELECT, INSERT, UPDATE, DELETE
113 public.archive = SELECT, INSERT, UPDATE
114 public.archiveauthtoken = SELECT, INSERT, UPDATE
115+public.archivejob = SELECT, INSERT, UPDATE, DELETE
116 public.archivesubscriber = SELECT, INSERT, UPDATE
117 public.archivearch = SELECT, INSERT, UPDATE, DELETE
118 public.archivedependency = SELECT, INSERT, DELETE

Subscribers

People subscribed via source and target branches

to status/vote changes: