xtablo-source/supabase/migrations_backup/16_create_calendar_sync_table.sql
2025-11-06 08:37:52 +01:00

14 lines
546 B
SQL

CREATE TABLE calendar_subscriptions (
id UUID DEFAULT gen_random_uuid() PRIMARY KEY,
tablo_id TEXT NOT NULL UNIQUE REFERENCES tablos(id) ON DELETE CASCADE,
token TEXT NOT NULL UNIQUE,
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);
-- Create index on token for fast lookups
CREATE INDEX idx_calendar_subscriptions_token ON calendar_subscriptions(token);
-- Note: Index on tablo_id is automatically created due to UNIQUE constraint
-- Enable Row Level Security
ALTER TABLE calendar_subscriptions ENABLE ROW LEVEL SECURITY;