1CREATE TABLE servers (
2 id SERIAL PRIMARY KEY,
3 environment VARCHAR NOT NULL
4);
5
6DELETE FROM projects;
7ALTER TABLE projects
8 DROP COLUMN host_connection_epoch,
9 ADD COLUMN host_connection_server_id INTEGER NOT NULL REFERENCES servers (id) ON DELETE CASCADE;
10
11DELETE FROM project_collaborators;
12ALTER TABLE project_collaborators
13 DROP COLUMN connection_epoch,
14 ADD COLUMN connection_server_id INTEGER NOT NULL REFERENCES servers (id) ON DELETE CASCADE;
15CREATE INDEX "index_project_collaborators_on_connection_server_id" ON "project_collaborators" ("connection_server_id");
16CREATE UNIQUE INDEX "index_project_collaborators_on_project_id_connection_id_and_server_id" ON "project_collaborators" ("project_id", "connection_id", "connection_server_id");
17
18DELETE FROM room_participants;
19ALTER TABLE room_participants
20 DROP COLUMN answering_connection_epoch,
21 DROP COLUMN calling_connection_epoch,
22 ADD COLUMN answering_connection_server_id INTEGER REFERENCES servers (id) ON DELETE CASCADE,
23 ADD COLUMN calling_connection_server_id INTEGER REFERENCES servers (id) ON DELETE SET NULL;
24CREATE INDEX "index_room_participants_on_answering_connection_server_id" ON "room_participants" ("answering_connection_server_id");
25CREATE INDEX "index_room_participants_on_calling_connection_server_id" ON "room_participants" ("calling_connection_server_id");
26CREATE UNIQUE INDEX "index_room_participants_on_answering_connection_id_and_answering_connection_server_id" ON "room_participants" ("answering_connection_id", "answering_connection_server_id");