← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~pappacena/launchpad:merge-db-stable into launchpad:master

 

Thiago F. Pappacena has proposed merging ~pappacena/launchpad:merge-db-stable into launchpad:master.

Commit message:
Merge db-stable 6d412dafb1959d2eef85de03c10e924666d2fa51 (MessageRevision and MessageRevisionChunk tables, and adding columns for last edit and delete date on Message)

Requested reviews:
  Thiago F. Pappacena (pappacena)

For more details, see:
https://code.launchpad.net/~pappacena/launchpad/+git/launchpad/+merge/403066
-- 
Your team Launchpad code reviewers is subscribed to branch ~pappacena/launchpad:merge-db-stable.
diff --git a/database/schema/patch-2210-31-0.sql b/database/schema/patch-2210-31-0.sql
new file mode 100644
index 0000000..8c11aac
--- /dev/null
+++ b/database/schema/patch-2210-31-0.sql
@@ -0,0 +1,50 @@
+-- Copyright 2021 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 Message
+    ADD COLUMN date_deleted timestamp without time zone,
+    ADD COLUMN date_last_edited timestamp without time zone;
+
+CREATE TABLE MessageRevision (
+    id serial PRIMARY KEY,
+    message integer NOT NULL REFERENCES Message,
+    revision integer NOT NULL,
+    subject text,
+    date_created timestamp without time zone NOT NULL,
+    date_deleted timestamp without time zone
+) WITH (fillfactor='100');
+
+CREATE UNIQUE INDEX messagerevision__message__revision__key
+    ON MessageRevision(message, revision);
+
+COMMENT ON TABLE MessageRevision IS 'Old versions of an edited Message';
+COMMENT ON COLUMN MessageRevision.message
+    IS 'The current message of this revision';
+COMMENT ON COLUMN MessageRevision.revision
+    IS 'The revision monotonic increasing number';
+COMMENT ON COLUMN MessageRevision.date_created
+    IS 'When the original message was edited and created this revision';
+COMMENT ON COLUMN MessageRevision.date_deleted
+    IS 'If this revision was deleted, when did that happen';
+
+
+CREATE TABLE MessageRevisionChunk (
+    id serial PRIMARY KEY,
+    messagerevision integer NOT NULL REFERENCES MessageRevision,
+    sequence integer NOT NULL,
+    content text NOT NULL
+) WITH (fillfactor='100');
+
+CREATE UNIQUE INDEX messagerevisionchunk__messagerevision__sequence__key
+    ON MessageRevisionChunk(messagerevision, sequence);
+
+COMMENT ON TABLE MessageRevisionChunk
+    IS 'Old chunks of a message when a revision was created for it';
+COMMENT ON COLUMN MessageRevisionChunk.sequence
+    IS 'Order of this particular chunk';
+COMMENT ON COLUMN MessageRevisionChunk.content
+    IS 'Text content for this chunk of the message.';
+
+INSERT INTO LaunchpadDatabaseRevision VALUES (2210, 31, 0);

References