#!/bin/bash # Migration script to add missing columns to existing tables # This script addresses the issue where init-db.sh skipped adding new columns to existing tables echo "Adding missing columns to existing tables..." # Add photos and featured_photo columns to rooms table if they don't exist psql -U lahuasca -d lahuasca -c "ALTER TABLE rooms ADD COLUMN IF NOT EXISTS photos TEXT[];" psql -U lahuasca -d lahuasca -c "ALTER TABLE rooms ADD COLUMN IF NOT EXISTS featured_photo VARCHAR(500);" # Add photos and featured_photo columns to places table if they don't exist psql -U lahuasca -d lahuasca -c "ALTER TABLE places ADD COLUMN IF NOT EXISTS photos TEXT[];" psql -U lahuasca -d lahuasca -c "ALTER TABLE places ADD COLUMN IF NOT EXISTS featured_photo VARCHAR(500);" # Add photos and featured_photo columns to menu_items table if they don't exist psql -U lahuasca -d lahuasca -c "ALTER TABLE menu_items ADD COLUMN IF NOT EXISTS photos TEXT[];" psql -U lahuasca -d lahuasca -c "ALTER TABLE menu_items ADD COLUMN IF NOT EXISTS featured_photo VARCHAR(500);" # Add first_name and last_name columns to users table if they don't exist psql -U lahuasca -d lahuasca -c "ALTER TABLE users ADD COLUMN IF NOT EXISTS first_name VARCHAR(255);" psql -U lahuasca -d lahuasca -c "ALTER TABLE users ADD COLUMN IF NOT EXISTS last_name VARCHAR(255);" # Add comments_disabled column to users table if it doesn't exist psql -U lahuasca -d lahuasca -c "ALTER TABLE users ADD COLUMN IF NOT EXISTS comments_disabled BOOLEAN DEFAULT false;" # Add featured_photo column to reservations table if it doesn't exist psql -U lahuasca -d lahuasca -c "ALTER TABLE reservations ADD COLUMN IF NOT EXISTS featured_photo VARCHAR(500);" # Add featured_photo column to social_events table if it doesn't exist psql -U lahuasca -d lahuasca -c "ALTER TABLE social_events ADD COLUMN IF NOT EXISTS featured_photo VARCHAR(500);" # Add featured_photo column to reviews table if it doesn't exist psql -U lahuasca -d lahuasca -c "ALTER TABLE reviews ADD COLUMN IF NOT EXISTS featured_photo VARCHAR(500);" # Add featured_photo column to social_event_reservations table if it doesn't exist psql -U lahuasca -d lahuasca -c "ALTER TABLE social_event_reservations ADD COLUMN IF NOT EXISTS featured_photo VARCHAR(500);" # Add featured_photo column to calendar_events table if it doesn't exist psql -U lahuasca -d lahuasca -c "ALTER TABLE calendar_events ADD COLUMN IF NOT EXISTS featured_photo VARCHAR(500);" # Add featured_photo column to room_comments table if it doesn't exist psql -U lahuasca -d lahuasca -c "ALTER TABLE room_comments ADD COLUMN IF NOT EXISTS featured_photo VARCHAR(500);" # Add featured_photo column to offers table if it doesn't exist psql -U lahuasca -d lahuasca -c "ALTER TABLE offers ADD COLUMN IF NOT EXISTS featured_photo VARCHAR(500);" # Add featured_photo column to coupons table if it doesn't exist psql -U lahuasca -d lahuasca -c "ALTER TABLE coupons ADD COLUMN IF NOT EXISTS featured_photo VARCHAR(500);" # Add featured_photo column to benefits table if it doesn't exist psql -U lahuasca -d lahuasca -c "ALTER TABLE benefits ADD COLUMN IF NOT EXISTS featured_photo VARCHAR(500);" # Add featured_photo column to slides table if it doesn't exist psql -U lahuasca -d lahuasca -c "ALTER TABLE slides ADD COLUMN IF NOT EXISTS featured_photo VARCHAR(500);" # Add featured_photo column to config table if it doesn't exist psql -U lahuasca -d lahuasca -c "ALTER TABLE config ADD COLUMN IF NOT EXISTS featured_photo VARCHAR(500);" echo "Migration completed successfully!"