Initial commit: monorepo Naturcalabacera reservas (apps/api + apps/web + packages/shared)

This commit is contained in:
2026-04-30 10:09:44 +01:00
commit a0ccb8ca64
188 changed files with 16418 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
-- Migration: Add observations column
alter table public.reservations add column observations text;

View File

@@ -0,0 +1,62 @@
-- Migration 002: Add contract_url column + create storage buckets for contracts
-- Schema: natur_reservas
-- Run this in the Supabase SQL editor
-- ── 1. Add contract_url column ────────────────────────────────────────────────
ALTER TABLE natur_reservas.reservations
ADD COLUMN IF NOT EXISTS contract_url text;
-- ── 2. Create storage buckets (one per property) ─────────────────────────────
INSERT INTO storage.buckets (id, name, public, file_size_limit, allowed_mime_types)
VALUES
(
'contratos-los-dragos',
'contratos-los-dragos',
true,
10485760, -- 10 MB
ARRAY['application/pdf', 'image/jpeg', 'image/png']
),
(
'contratos-la-esquinita',
'contratos-la-esquinita',
true,
10485760,
ARRAY['application/pdf', 'image/jpeg', 'image/png']
)
ON CONFLICT (id) DO NOTHING;
-- ── 3. Storage RLS policies ───────────────────────────────────────────────────
-- contratos-los-dragos
CREATE POLICY "contratos-los-dragos: select"
ON storage.objects FOR SELECT TO anon, authenticated
USING (bucket_id = 'contratos-los-dragos');
CREATE POLICY "contratos-los-dragos: insert"
ON storage.objects FOR INSERT TO anon, authenticated
WITH CHECK (bucket_id = 'contratos-los-dragos');
CREATE POLICY "contratos-los-dragos: update"
ON storage.objects FOR UPDATE TO anon, authenticated
USING (bucket_id = 'contratos-los-dragos');
CREATE POLICY "contratos-los-dragos: delete"
ON storage.objects FOR DELETE TO anon, authenticated
USING (bucket_id = 'contratos-los-dragos');
-- contratos-la-esquinita
CREATE POLICY "contratos-la-esquinita: select"
ON storage.objects FOR SELECT TO anon, authenticated
USING (bucket_id = 'contratos-la-esquinita');
CREATE POLICY "contratos-la-esquinita: insert"
ON storage.objects FOR INSERT TO anon, authenticated
WITH CHECK (bucket_id = 'contratos-la-esquinita');
CREATE POLICY "contratos-la-esquinita: update"
ON storage.objects FOR UPDATE TO anon, authenticated
USING (bucket_id = 'contratos-la-esquinita');
CREATE POLICY "contratos-la-esquinita: delete"
ON storage.objects FOR DELETE TO anon, authenticated
USING (bucket_id = 'contratos-la-esquinita');

View File

@@ -0,0 +1,54 @@
-- Migration 003: Create contracts storage bucket + reservation_contracts table
-- Schema: natur_reservas
-- Run in Supabase SQL editor
-- ── 1. Storage bucket (privado, usa signed URLs) ──────────────────────────────
INSERT INTO storage.buckets (id, name, public, file_size_limit, allowed_mime_types)
VALUES (
'contracts',
'contracts',
false,
10485760,
ARRAY['application/pdf', 'image/jpeg', 'image/png']
)
ON CONFLICT (id) DO NOTHING;
-- Storage RLS policies
CREATE POLICY "contracts: select"
ON storage.objects FOR SELECT TO anon, authenticated
USING (bucket_id = 'contracts');
CREATE POLICY "contracts: insert"
ON storage.objects FOR INSERT TO anon, authenticated
WITH CHECK (bucket_id = 'contracts');
CREATE POLICY "contracts: update"
ON storage.objects FOR UPDATE TO anon, authenticated
USING (bucket_id = 'contracts');
CREATE POLICY "contracts: delete"
ON storage.objects FOR DELETE TO anon, authenticated
USING (bucket_id = 'contracts');
-- ── 2. Tabla reservation_contracts ────────────────────────────────────────────
CREATE TABLE IF NOT EXISTS natur_reservas.reservation_contracts (
id uuid DEFAULT gen_random_uuid() PRIMARY KEY,
created_at timestamp with time zone DEFAULT timezone('utc', now()) NOT NULL,
reservation_id uuid NOT NULL REFERENCES natur_reservas.reservations(id) ON DELETE CASCADE,
file_path text NOT NULL,
filename text NOT NULL,
mime_type text NOT NULL,
size_bytes integer NOT NULL,
uploaded_by uuid REFERENCES auth.users(id)
);
ALTER TABLE natur_reservas.reservation_contracts ENABLE ROW LEVEL SECURITY;
CREATE POLICY "rc: select" ON natur_reservas.reservation_contracts
FOR SELECT TO anon, authenticated USING (true);
CREATE POLICY "rc: insert" ON natur_reservas.reservation_contracts
FOR INSERT TO anon, authenticated WITH CHECK (true);
CREATE POLICY "rc: delete" ON natur_reservas.reservation_contracts
FOR DELETE TO anon, authenticated USING (true);