-- 1. Table for marketing banners
create table if not exists flowhub_banners (
id text primary key,
created_at timestamp with time zone default now(),
lang text not null,
title text not null,
description text,
link text,
image text,
mockup_type text not null
);
alter table flowhub_banners enable row level security;
create policy "Allow public read" on flowhub_banners for select using (true);
create policy "Allow public insert" on flowhub_banners for insert with check (true);
create policy "Allow public update" on flowhub_banners for update using (true);
create policy "Allow public delete" on flowhub_banners for delete using (true);
-- 2. Table for hotel demo registrations (leads)
create table if not exists flowhub_leads (
id uuid default gen_random_uuid() primary key,
created_at timestamp with time zone default now(),
name text not null,
hotel_name text not null,
email text not null,
phone text not null,
rooms integer not null,
modules text[] not null,
status text default 'pending'
);
alter table flowhub_leads enable row level security;
create policy "Allow public insert" on flowhub_leads for insert with check (true);
create policy "Allow public read" on flowhub_leads for select using (true);
-- 3. Table for proposals (ใบเสนอราคา)
create table if not exists flowhub_proposals (
id uuid default gen_random_uuid() primary key,
created_at timestamp with time zone default now(),
proposal_number text not null,
hotel_name text not null,
company_name text,
rooms integer not null,
selected_modules text[] not null,
monthly_price_per_room numeric not null,
total_monthly_price numeric not null,
billing_cycle text not null default 'monthly',
contact_name text,
contact_email text,
contact_phone text,
valid_until date,
notes text,
status text default 'draft'
);
alter table flowhub_proposals enable row level security;
create policy "Allow public read" on flowhub_proposals for select using (true);
create policy "Allow public insert" on flowhub_proposals for insert with check (true);
create policy "Allow public update" on flowhub_proposals for update using (true);
create policy "Allow public delete" on flowhub_proposals for delete using (true);
-- 4. Table for hotel subscriptions (ลิขสิทธิ์และการเรียกเก็บเงิน)
create table if not exists flowhub_subscriptions (
id uuid default gen_random_uuid() primary key,
updated_at timestamp with time zone default now(),
hotel_id text unique not null,
hotel_name text not null,
pms_status text default 'active',
pms_expires_at date,
cm_status text default 'active',
cm_expires_at date,
connect_status text default 'active',
connect_expires_at date,
stay_status text default 'active',
stay_expires_at date
);
alter table flowhub_subscriptions enable row level security;
create policy "Allow public read" on flowhub_subscriptions for select using (true);
create policy "Allow public insert" on flowhub_subscriptions for insert with check (true);
create policy "Allow public update" on flowhub_subscriptions for update using (true);
create policy "Allow public delete" on flowhub_subscriptions for delete using (true);
-- 5. Table for support tickets (แจ้งปัญหาการใช้งาน)
create table if not exists flowhub_tickets (
id uuid default gen_random_uuid() primary key,
created_at timestamp with time zone default now(),
hotel_name text not null,
problem_desc text not null,
contact_info text not null,
status text default 'open'
);
alter table flowhub_tickets enable row level security;
create policy "Allow public read" on flowhub_tickets for select using (true);
create policy "Allow public insert" on flowhub_tickets for insert with check (true);
create policy "Allow public update" on flowhub_tickets for update using (true);
create policy "Allow public delete" on flowhub_tickets for delete using (true);