#!/usr/bin/env python3
"""
Check current restaurants table schema
"""

from sqlalchemy import create_engine, text
from urllib.parse import quote_plus

def check_restaurants_schema():
    DATABASE_URL = f"postgresql://postgres:{quote_plus('F@f@k0s!!')}@localhost:5432/bookbeach"
    engine = create_engine(DATABASE_URL)
    
    with engine.connect() as db:
        result = db.execute(text("""
            SELECT column_name, data_type, is_nullable
            FROM information_schema.columns 
            WHERE table_name = 'restaurants' 
            ORDER BY ordinal_position
        """)).fetchall()
        
        print('Restaurants table columns:')
        for col_name, data_type, is_nullable in result:
            print(f'  {col_name}: {data_type} (nullable: {is_nullable})')
        
        # Check for indexes and constraints
        result = db.execute(text("""
            SELECT conname, contype 
            FROM pg_constraint 
            WHERE conrelid = 'restaurants'::regclass
        """)).fetchall()
        
        print('\nConstraints:')
        for name, type_code in result:
            constraint_type = {'p': 'PRIMARY KEY', 'f': 'FOREIGN KEY', 'u': 'UNIQUE', 'c': 'CHECK'}.get(type_code, type_code)
            print(f'  {name}: {constraint_type}')

if __name__ == '__main__':
    check_restaurants_schema()