"""update products

Revision ID: ef40913679bd
Revises: 2325dd0f1bd5
Create Date: 2025-03-02 16:44:41.367742

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = 'ef40913679bd'
down_revision: Union[str, None] = '2325dd0f1bd5'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('collections', sa.Column('description', sa.Text(), nullable=True))
    op.add_column('collections', sa.Column('is_active', sa.Boolean(), nullable=True))
    op.add_column('collections', sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True))
    op.add_column('collections', sa.Column('updated_at', sa.DateTime(timezone=True), nullable=True))
    op.add_column('product_variants', sa.Column('price', sa.Float(), nullable=False))
    op.add_column('product_variants', sa.Column('discount_price', sa.Float(), nullable=True))
    op.drop_column('product_variants', 'price_adjustment')
    op.add_column('products', sa.Column('collection_id', sa.Integer(), nullable=True))
    op.create_foreign_key(None, 'products', 'collections', ['collection_id'], ['id'])
    op.drop_column('products', 'discount_price')
    op.drop_column('products', 'price')
    op.drop_column('products', 'stock')
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('products', sa.Column('stock', sa.INTEGER(), autoincrement=False, nullable=True))
    op.add_column('products', sa.Column('price', sa.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=False))
    op.add_column('products', sa.Column('discount_price', sa.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=True))
    op.drop_constraint(None, 'products', type_='foreignkey')
    op.drop_column('products', 'collection_id')
    op.add_column('product_variants', sa.Column('price_adjustment', sa.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=True))
    op.drop_column('product_variants', 'discount_price')
    op.drop_column('product_variants', 'price')
    op.drop_column('collections', 'updated_at')
    op.drop_column('collections', 'created_at')
    op.drop_column('collections', 'is_active')
    op.drop_column('collections', 'description')
    # ### end Alembic commands ###
