summary refs log tree commit diff
diff options
context:
space:
mode:
authorLuke Barnard <lukeb@openmarket.com>2017-10-26 17:55:22 +0100
committerLuke Barnard <lukeb@openmarket.com>2017-10-26 17:55:22 +0100
commit007cd48af67576df23e988ea8a4abcbc64396c6a (patch)
tree487553fc83a5a752d71e51c785c044db46ef425d
parentAwful hack to get default true (diff)
downloadsynapse-007cd48af67576df23e988ea8a4abcbc64396c6a.tar.xz
Recreate groups table instead of adding column
Adding a column with non-constant default not possible in sqlite3
-rw-r--r--synapse/storage/schema/delta/46/group_server.sql18
1 files changed, 16 insertions, 2 deletions
diff --git a/synapse/storage/schema/delta/46/group_server.sql b/synapse/storage/schema/delta/46/group_server.sql
index a892cff7e5..e754b554f8 100644
--- a/synapse/storage/schema/delta/46/group_server.sql
+++ b/synapse/storage/schema/delta/46/group_server.sql
@@ -13,6 +13,20 @@
  * limitations under the License.
  */
 
--- whether non-members can access group APIs
+CREATE TABLE groups_new (
+    group_id TEXT NOT NULL,
+    name TEXT,  -- the display name of the room
+    avatar_url TEXT,
+    short_description TEXT,
+    long_description TEXT,
+    is_public BOOL NOT NULL -- whether non-members can access group APIs
+);
+
 -- NB: awful hack to get the default to be true on postgres and 1 on sqlite
-ALTER TABLE groups ADD COLUMN is_public BOOL DEFAULT (1=1) NOT NULL;
+INSERT INTO groups_new
+    SELECT group_id, name, avatar_url, short_description, long_description, (1=1) FROM groups;
+
+DROP TABLE groups;
+ALTER TABLE groups_new RENAME TO groups;
+
+CREATE UNIQUE INDEX groups_idx ON groups(group_id);