← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~cjwatson/launchpad/db-snap-job into lp:launchpad/db-devel

 

Colin Watson has proposed merging lp:~cjwatson/launchpad/db-snap-job into lp:launchpad/db-devel.

Commit message:
Add SnapJob table.

Requested reviews:
  Stuart Bishop (stub): db
  Launchpad code reviewers (launchpad-reviewers): db
Related bugs:
  Bug #1770400 in Launchpad itself: "Support snapcraft architectures keyword"
  https://bugs.launchpad.net/launchpad/+bug/1770400

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/db-snap-job/+merge/348057

We have SnapBuildJob already, but Snap.requestBuilds is going to need an asynchronous job that's associated with a Snap but not with any particular SnapBuild.

Long-term we perhaps ought to consolidate these two tables into SnapJob (and I should have done it that way to start with), but there's no particular urgency.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/db-snap-job into lp:launchpad/db-devel.
=== added file 'database/schema/patch-2209-83-3.sql'
--- database/schema/patch-2209-83-3.sql	1970-01-01 00:00:00 +0000
+++ database/schema/patch-2209-83-3.sql	2018-06-15 12:59:59 +0000
@@ -0,0 +1,22 @@
+-- Copyright 2018 Canonical Ltd.  This software is licensed under the
+-- GNU Affero General Public License version 3 (see the file LICENSE).
+
+SET client_min_messages=ERROR;
+
+CREATE TABLE SnapJob (
+    job integer PRIMARY KEY REFERENCES Job ON DELETE CASCADE NOT NULL,
+    snap integer REFERENCES Snap NOT NULL,
+    job_type integer NOT NULL,
+    json_data text NOT NULL
+);
+
+CREATE INDEX snapjob__snap__job_type__job__idx
+    ON SnapJob(snap, job_type, job);
+
+COMMENT ON TABLE SnapJob IS 'Contains references to jobs that are executed for a snap package.';
+COMMENT ON COLUMN SnapJob.job IS 'A reference to a Job row that has all the common job details.';
+COMMENT ON COLUMN SnapJob.snap IS 'The snap package that this job is for.';
+COMMENT ON COLUMN SnapJob.job_type IS 'The type of a job, such as a build request.';
+COMMENT ON COLUMN SnapJob.json_data IS 'Data that is specific to a particular job type.';
+
+INSERT INTO LaunchpadDatabaseRevision VALUES (2209, 83, 3);