-- BAHAMASCHATS.COM SUPABASE TABLES
-- Run this in SQL Editor
-- 1. PROFILES (real logins)
create table if not exists profiles (
id uuid primary key default gen_random_uuid(),
username text unique not null,
email text unique not null,
password text not null,
pic text,
created_at timestamp default now()
);
alter table profiles enable row level security;
create policy "allow all" on profiles for all using (true) with check (true);
-- 2. ROOMS
create table if not exists rooms (
id text primary key,
name text not null,
description text,
owner text not null,
owner_pic text,
locked boolean default false,
password text,
created_at bigint
);
alter table rooms enable row level security;
create policy "allow all" on rooms for all using (true) with check (true);
-- 3. MESSAGES (main + rooms + DMs)
create table if not exists messages (
id uuid primary key default gen_random_uuid(),
username text not null,
pic text,
text text,
photo text,
gif text,
voice text,
room_id text,
is_dm boolean default false,
to_user text,
owner text,
created_at bigint
);
alter table messages enable row level security;
create policy "allow all" on messages for all using (true) with check (true);
-- Enable realtime
alter publication supabase_realtime add table messages;
alter publication supabase_realtime add table rooms;