"""Add site_settings table

Revision ID: 9faab7ef6036
Revises: ca9026520dad
Create Date: 2025-05-25 21:16:39.683736

"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy import inspect
from sqlalchemy.dialects import postgresql


# revision identifiers, used by Alembic.
revision = '9faab7ef6036'
down_revision = 'ca9026520dad'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    conn = op.get_bind()
    inspector = inspect(conn)
    tables = inspector.get_table_names()
    
    if 'site_settings' not in tables:
        op.create_table('site_settings',
            sa.Column('id', sa.Integer(), nullable=False),
            sa.Column('primary_color', sa.String(length=7), nullable=True),
            sa.Column('secondary_color', sa.String(length=7), nullable=True),
            sa.Column('updated_at', sa.DateTime(), nullable=True),
            sa.PrimaryKeyConstraint('id')
        )
    op.drop_table('color_settings')
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    conn = op.get_bind()
    inspector = inspect(conn)
    tables = inspector.get_table_names()
    
    if 'color_settings' not in tables:
        op.create_table('color_settings',
            sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
            sa.Column('primary_color', sa.VARCHAR(length=7), autoincrement=False, nullable=True),
            sa.Column('secondary_color', sa.VARCHAR(length=7), autoincrement=False, nullable=True),
            sa.Column('updated_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=True),
            sa.PrimaryKeyConstraint('id', name=op.f('color_settings_pkey'))
        )
    op.drop_table('site_settings')
    # ### end Alembic commands ### 