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

Proposed by Thiago F. Pappacena
Status: Merged
Approved by: Thiago F. Pappacena
Approved revision: 6d412dafb1959d2eef85de03c10e924666d2fa51
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~pappacena/launchpad:merge-db-stable
Merge into: launchpad:master
Diff against target: 56 lines (+50/-0)
1 file modified
database/schema/patch-2210-31-0.sql (+50/-0)
Reviewer Review Type Date Requested Status
Thiago F. Pappacena (community) Approve
Review via email: mp+403066@code.launchpad.net

Commit message

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

To post a comment you must log in.
Revision history for this message
Thiago F. Pappacena (pappacena) wrote :

Deployed to the production database today.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/database/schema/patch-2210-31-0.sql b/database/schema/patch-2210-31-0.sql
0new file mode 1006440new file mode 100644
index 0000000..8c11aac
--- /dev/null
+++ b/database/schema/patch-2210-31-0.sql
@@ -0,0 +1,50 @@
1-- Copyright 2021 Canonical Ltd. This software is licensed under the
2-- GNU Affero General Public License version 3 (see the file LICENSE).
3
4SET client_min_messages=ERROR;
5
6ALTER TABLE Message
7 ADD COLUMN date_deleted timestamp without time zone,
8 ADD COLUMN date_last_edited timestamp without time zone;
9
10CREATE TABLE MessageRevision (
11 id serial PRIMARY KEY,
12 message integer NOT NULL REFERENCES Message,
13 revision integer NOT NULL,
14 subject text,
15 date_created timestamp without time zone NOT NULL,
16 date_deleted timestamp without time zone
17) WITH (fillfactor='100');
18
19CREATE UNIQUE INDEX messagerevision__message__revision__key
20 ON MessageRevision(message, revision);
21
22COMMENT ON TABLE MessageRevision IS 'Old versions of an edited Message';
23COMMENT ON COLUMN MessageRevision.message
24 IS 'The current message of this revision';
25COMMENT ON COLUMN MessageRevision.revision
26 IS 'The revision monotonic increasing number';
27COMMENT ON COLUMN MessageRevision.date_created
28 IS 'When the original message was edited and created this revision';
29COMMENT ON COLUMN MessageRevision.date_deleted
30 IS 'If this revision was deleted, when did that happen';
31
32
33CREATE TABLE MessageRevisionChunk (
34 id serial PRIMARY KEY,
35 messagerevision integer NOT NULL REFERENCES MessageRevision,
36 sequence integer NOT NULL,
37 content text NOT NULL
38) WITH (fillfactor='100');
39
40CREATE UNIQUE INDEX messagerevisionchunk__messagerevision__sequence__key
41 ON MessageRevisionChunk(messagerevision, sequence);
42
43COMMENT ON TABLE MessageRevisionChunk
44 IS 'Old chunks of a message when a revision was created for it';
45COMMENT ON COLUMN MessageRevisionChunk.sequence
46 IS 'Order of this particular chunk';
47COMMENT ON COLUMN MessageRevisionChunk.content
48 IS 'Text content for this chunk of the message.';
49
50INSERT INTO LaunchpadDatabaseRevision VALUES (2210, 31, 0);