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 (community) 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
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);