mirror of
https://github.com/polaroi8d/cactoide.git
synced 2026-03-22 06:05:28 +00:00
Initial commit
This commit is contained in:
34
migration-add-user-id-to-rsvps.sql
Normal file
34
migration-add-user-id-to-rsvps.sql
Normal file
@@ -0,0 +1,34 @@
|
||||
-- Migration: Add user_id column to RSVPs table
|
||||
-- Run this against your existing Supabase database
|
||||
|
||||
-- Add user_id column to existing rsvps table
|
||||
ALTER TABLE rsvps
|
||||
ADD COLUMN user_id VARCHAR(100);
|
||||
|
||||
-- Set a default value for existing records (you can modify this if needed)
|
||||
-- This assigns a unique user ID to each existing RSVP
|
||||
UPDATE rsvps
|
||||
SET user_id = 'legacy_user_' || id::text
|
||||
WHERE user_id IS NULL;
|
||||
|
||||
-- Make the column NOT NULL after setting default values
|
||||
ALTER TABLE rsvps
|
||||
ALTER COLUMN user_id SET NOT NULL;
|
||||
|
||||
-- Add index for better performance
|
||||
CREATE INDEX IF NOT EXISTS idx_rsvps_user_id ON rsvps(user_id);
|
||||
|
||||
-- Verify the migration
|
||||
SELECT
|
||||
column_name,
|
||||
data_type,
|
||||
is_nullable,
|
||||
column_default
|
||||
FROM information_schema.columns
|
||||
WHERE table_name = 'rsvps'
|
||||
AND column_name = 'user_id';
|
||||
|
||||
-- Show sample of updated data
|
||||
SELECT id, name, user_id, created_at
|
||||
FROM rsvps
|
||||
LIMIT 5;
|
||||
Reference in New Issue
Block a user