19 lines
715 B
SQL
19 lines
715 B
SQL
-- Migration to convert room_members table to use UUIDs for ID
|
|
-- We will recreate the table to ensure clean state
|
|
|
|
DROP TABLE IF EXISTS room_members;
|
|
|
|
CREATE TABLE room_members (
|
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
room_id UUID NOT NULL REFERENCES rooms(id) ON DELETE CASCADE,
|
|
user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
|
role VARCHAR(50) NOT NULL DEFAULT 'member',
|
|
joined_at TIMESTAMPTZ DEFAULT NOW(),
|
|
|
|
CONSTRAINT uq_room_members_room_user UNIQUE (room_id, user_id)
|
|
);
|
|
|
|
CREATE INDEX idx_room_members_room_id ON room_members(room_id);
|
|
CREATE INDEX idx_room_members_user_id ON room_members(user_id);
|
|
CREATE INDEX idx_room_members_role ON room_members(role);
|
|
|