fix: Correct latest migration alembic/versions/20250414_010203_5350732a_update_grocery.py via AI
This commit is contained in:
parent
fe37aefdf8
commit
475e1e4b79
@ -6,14 +6,23 @@ Create Date: 2024-01-30 10:00:00.000000
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '9a4c2e7d'
|
||||
down_revision = '8f2b3d5c'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.add_column('groceries', sa.Column('color', sa.String(), nullable=True))
|
||||
# SQLite doesn't support adding a column with a default value directly
|
||||
# We need to use batch_alter_table for SQLite compatibility
|
||||
with op.batch_alter_table('groceries') as batch_op:
|
||||
batch_op.add_column(sa.Column('color', sa.String(), nullable=True))
|
||||
batch_op.create_index('ix_groceries_name', ['name'])
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_column('groceries', 'color')
|
||||
with op.batch_alter_table('groceries') as batch_op:
|
||||
batch_op.drop_index('ix_groceries_name')
|
||||
batch_op.drop_column('color')
|
Loading…
x
Reference in New Issue
Block a user