wiki.techinc.nl/maintenance/postgres/archives/patch-comment-table.sql
Brad Jorsch 91b86399b1 Fix various PostgreSQL failures
* Fix schema for image_comment_temp.
* Provide values in CommentStoreTest::provideInsertRoundTrip() for
  columns where the PG schema doesn't have a default value but the MySQL
  schema does.
* Call nextSequenceValue() from CommentStoreTest::testInsertRoundTrip().
* Correctly handle $options being the string 'FOR UPDATE' in
  DatabasePostgres::selectSQLText()
* Correctly handle the initial table in DatabasePostgres::selectSQLText() FOR
  UPDATE mangling.
* Correctly handle aliases in DatabasePostgres::selectSQLText() FOR
  UPDATE mangling.

Tests in PG are still going to be broken thanks to the fact that
nextSequenceValue() and insertId() can't be separated by another
nextSequenceValue()/insertId() pair. That should be taken care of by
T164898/T164900.

Change-Id: Ia770a003ca9170ab8bcc1436d8afe30700e00ada
2017-08-30 17:18:29 -04:00

27 lines
905 B
SQL

--
-- patch-comment-table.sql
--
-- T166732. Add a `comment` table, and temporary tables to reference it.
CREATE SEQUENCE comment_comment_id_seq;
CREATE TABLE comment (
comment_id INTEGER NOT NULL PRIMARY KEY DEFAULT nextval('comment_comment_id_seq'),
comment_hash INTEGER NOT NULL,
comment_text TEXT NOT NULL,
comment_data TEXT
);
CREATE INDEX comment_hash ON comment (comment_hash);
CREATE TABLE revision_comment_temp (
revcomment_rev INTEGER NOT NULL,
revcomment_comment_id INTEGER NOT NULL,
PRIMARY KEY (revcomment_rev, revcomment_comment_id)
);
CREATE UNIQUE INDEX revcomment_rev ON revision_comment_temp (revcomment_rev);
CREATE TABLE image_comment_temp (
imgcomment_name TEXT NOT NULL,
imgcomment_description_id INTEGER NOT NULL,
PRIMARY KEY (imgcomment_name, imgcomment_description_id)
);
CREATE UNIQUE INDEX imgcomment_name ON image_comment_temp (imgcomment_name);