Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Recreate groups table instead of adding column
Browse files Browse the repository at this point in the history
Adding a column with non-constant default not possible in sqlite3
  • Loading branch information
Luke Barnard committed Oct 26, 2017
1 parent 713e60b commit 007cd48
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions synapse/storage/schema/delta/46/group_server.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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);

0 comments on commit 007cd48

Please sign in to comment.