Merge ~pappacena/launchpad:comment-editing-db-patch into launchpad:db-devel

Proposed by Thiago F. Pappacena
Status: Merged
Approved by: Thiago F. Pappacena
Approved revision: 6e82b256068825a8ff013c144fe15957ff7c2331
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~pappacena/launchpad:comment-editing-db-patch
Merge into: launchpad:db-devel
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
William Grant db Approve
Colin Watson Approve
Review via email: mp+401976@code.launchpad.net

Commit message

Database patch for comment editing feature

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) :
review: Needs Information
Revision history for this message
Thiago F. Pappacena (pappacena) :
Revision history for this message
Colin Watson (cjwatson) :
Revision history for this message
Thiago F. Pappacena (pappacena) wrote :

Pushed the requested changes. It worth another review round.

Revision history for this message
Colin Watson (cjwatson) :
review: Approve
Revision history for this message
Colin Watson (cjwatson) wrote :

Requested a second DB review from William.

Revision history for this message
Thiago F. Pappacena (pappacena) :
Revision history for this message
William Grant (wgrant) wrote :

Thanks, just a couple comments.

review: Approve (db)
Revision history for this message
Thiago F. Pappacena (pappacena) wrote :

Pushed the requested changes. This should be ready to be merged now.

Preview Diff

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