Spaces:
Runtime error
Runtime error
File size: 1,954 Bytes
f9b1caa | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | -- Create Fresh Generations Table for Voucher Generator
-- Run this in Supabase SQL Editor for a clean installation
-- Drop existing table if you want to start fresh (CAUTION: This deletes all data!)
-- DROP TABLE IF EXISTS public.generations;
-- Create the generations table with all required columns
CREATE TABLE IF NOT EXISTS public.generations (
-- Auto-generated fields
id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
created_at timestamptz NOT NULL DEFAULT now(),
-- Hotel information
hotel_name text NOT NULL,
city text,
address_line1 text,
address_line2 text,
phone text,
-- Guest information
primary_guest_name text NOT NULL,
num_guests integer NOT NULL DEFAULT 1,
num_rooms integer NOT NULL DEFAULT 1,
guest_details jsonb,
-- Booking dates
checkin_date date NOT NULL,
checkout_date date NOT NULL,
num_nights integer NOT NULL DEFAULT 1,
-- Room details
room_type text,
room_size text,
meal_plan text DEFAULT 'Breakfast Only',
-- Policy details
policy text DEFAULT 'Non-Refundable',
is_refundable boolean DEFAULT false,
cancellation_days integer,
remarks text,
-- PDF tracking
pdf_filename text NOT NULL,
pdf_url text,
pdf_storage_path text,
-- Metadata
tab_source text NOT NULL DEFAULT 'Search Hotel',
is_bulk boolean DEFAULT false
);
-- Create index on created_at for faster date range queries
CREATE INDEX IF NOT EXISTS idx_generations_created_at ON public.generations(created_at DESC);
-- Create index on hotel_name for faster searches
CREATE INDEX IF NOT EXISTS idx_generations_hotel_name ON public.generations(hotel_name);
-- Create index on checkin_date for date-based queries
CREATE INDEX IF NOT EXISTS idx_generations_checkin_date ON public.generations(checkin_date);
-- Verify table was created successfully
SELECT
'Table created successfully!' as status,
count(*) as column_count
FROM information_schema.columns
WHERE table_name = 'generations';
|