← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~twom/launchpad:db-ocifile-date-last-used into launchpad:db-devel

 

Tom Wardill has proposed merging ~twom/launchpad:db-ocifile-date-last-used into launchpad:db-devel.

Commit message:
Add OCIFile.date_last_used

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~twom/launchpad/+git/launchpad/+merge/384129

Add date_last_used for keeping track of when an OCIFile is used in an image build.
OCIFile is created at the point of first use, so defaulting to 'now' is a reasonable behaviour.

We have a handful of builds and files on production currently, so setting the default on column addition.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~twom/launchpad:db-ocifile-date-last-used into launchpad:db-devel.
diff --git a/database/schema/patch-2210-08-9.sql b/database/schema/patch-2210-08-9.sql
new file mode 100644
index 0000000..a50f25e
--- /dev/null
+++ b/database/schema/patch-2210-08-9.sql
@@ -0,0 +1,11 @@
+-- Copyright 2020 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 OCIFile
+ADD COLUMN date_last_used timestamp without time zone DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL;
+
+COMMENT ON COLUMN OCIFile.date_last_used IS 'The datetime this file was last used in a build.';
+
+INSERT INTO LaunchpadDatabaseRevision VALUES (2210, 08, 9);

Follow ups