-- Add missing columns to restaurants table
-- This migration adds phone, email, website, and updated_at columns

-- Add the missing columns
ALTER TABLE restaurants 
ADD COLUMN IF NOT EXISTS phone VARCHAR(20),
ADD COLUMN IF NOT EXISTS email VARCHAR(100),
ADD COLUMN IF NOT EXISTS website VARCHAR(500),
ADD COLUMN IF NOT EXISTS updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP;

-- Create index for email lookups
CREATE INDEX IF NOT EXISTS idx_restaurants_email ON restaurants(email);

-- Create index for phone lookups  
CREATE INDEX IF NOT EXISTS idx_restaurants_phone ON restaurants(phone);

-- Add comments for documentation
COMMENT ON COLUMN restaurants.phone IS 'Restaurant contact phone number';
COMMENT ON COLUMN restaurants.email IS 'Restaurant contact email address';
COMMENT ON COLUMN restaurants.website IS 'Restaurant website URL or social media page';
COMMENT ON COLUMN restaurants.updated_at IS 'Timestamp of last update to the restaurant record';

-- Verify the changes
SELECT column_name, data_type, is_nullable
FROM information_schema.columns 
WHERE table_name = 'restaurants' 
  AND column_name IN ('phone', 'email', 'website', 'updated_at')
ORDER BY column_name;