"""init

Revision ID: dd8d5991f03a
Revises: d1b48ef65028
Create Date: 2025-09-23 13:00:17.257247

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql

# revision identifiers, used by Alembic.
revision: str = 'dd8d5991f03a'
down_revision: Union[str, Sequence[str], None] = 'd1b48ef65028'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    """Upgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('shared_cart',
    sa.Column('shared_cart_id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('original_cart_id', sa.Integer(), nullable=False),
    sa.Column('customer_id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=255), nullable=False),
    sa.Column('seo_keyword', sa.String(length=255), nullable=False),
    sa.Column('date_added', sa.DateTime(), nullable=False),
    sa.PrimaryKeyConstraint('shared_cart_id'),
    sa.UniqueConstraint('seo_keyword')
    )
    op.create_table('shared_cart_product',
    sa.Column('shared_cart_product_id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('shared_cart_id', sa.Integer(), nullable=False),
    sa.Column('product_id', sa.Integer(), nullable=False),
    sa.Column('quantity', sa.Integer(), nullable=False),
    sa.Column('store_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['shared_cart_id'], ['shared_cart.shared_cart_id'], ondelete='CASCADE'),
    sa.PrimaryKeyConstraint('shared_cart_product_id')
    )
    op.create_foreign_key(None, 'cart_product', 'cart', ['cart_id'], ['cart_id'], ondelete='CASCADE')
    op.drop_constraint(op.f('product_review_ibfk_4'), 'product_review', type_='foreignkey')
    op.drop_column('product_review', 'store_id')
    # ### end Alembic commands ###


def downgrade() -> None:
    """Downgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('product_review', sa.Column('store_id', mysql.INTEGER(), autoincrement=False, nullable=True))
    op.create_foreign_key(op.f('product_review_ibfk_4'), 'product_review', 'store', ['store_id'], ['store_id'], ondelete='CASCADE')
    op.drop_constraint(None, 'cart_product', type_='foreignkey')
    op.drop_table('shared_cart_product')
    op.drop_table('shared_cart')
    # ### end Alembic commands ###
