From 50affc13a223b770351f268b110ffc8e0d6f4c8a Mon Sep 17 00:00:00 2001 From: muken Date: Sun, 28 Jun 2026 14:37:00 +0000 Subject: [PATCH] Add migration script to fix missing columns in existing tables --- migration-fix-columns.sh | 60 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 migration-fix-columns.sh diff --git a/migration-fix-columns.sh b/migration-fix-columns.sh new file mode 100644 index 0000000..b958743 --- /dev/null +++ b/migration-fix-columns.sh @@ -0,0 +1,60 @@ +#!/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!" \ No newline at end of file