"""add receiptitem names

Revision ID: 9a8c73f0ab11
Revises: 36f532800705
Create Date: 2023-11-18 23:38:56.865780

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '9a8c73f0ab11'
down_revision = '36f532800705'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table('receipt_item', schema=None) as batch_op:
        batch_op.add_column(sa.Column('name', sa.String(), nullable=True))
    op.execute("UPDATE receipt_item SET name='Unknown' WHERE name IS NULL;")
    with op.batch_alter_table('receipt_item', schema=None) as batch_op:
        batch_op.alter_column('name', nullable=False)

    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table('receipt_item', schema=None) as batch_op:
        batch_op.drop_column('name')

    # ### end Alembic commands ###
