-- Protocolo E.T.A.P.A - Fase de Arquitectura - DB Schema
-- Tabla: reservations

create type reservation_origin as enum ('Teneriffa2000', 'Naturcalabacera');

create table public.reservations (
  id uuid default gen_random_uuid() primary key,
  created_at timestamp with time zone default timezone('utc'::text, now()) not null,
  start_date date not null,
  end_date date not null,
  client_name text not null,
  origin reservation_origin not null,
  invoice_number text,
  adults_count integer default 0,
  children_count integer default 0,
  has_cleaning boolean default false,
  has_pool_heating boolean default false,
  has_flies_products boolean default false,
  has_flies_products boolean default false,
  government_registration text,
  observations text
);

-- Enable RLS
alter table public.reservations enable row level security;

-- Policies (DEV MODE: PUBLIC ACCESS)
-- Acceso Select: Permitir a todos (anon y authenticated)
create policy "Enable read access for all users" 
on public.reservations for select 
to anon, authenticated 
using (true);

-- Acceso Insert: Permitir a todos
create policy "Enable insert for all users" 
on public.reservations for insert 
to anon, authenticated 
with check (true);

-- Acceso Update: Permitir a todos
create policy "Enable update for all users" 
on public.reservations for update 
to anon, authenticated 
using (true);

-- Acceso Delete: Permitir a todos
create policy "Enable delete for all users" 
on public.reservations for delete 
to anon, authenticated 
using (true);
