fix: Migration e7f1a9c3b214 auch auf SQLite lauffähig (A14-T1 Fixrunde)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -23,10 +23,12 @@ def upgrade() -> None:
|
||||
# Bestandsdaten: percent/absolute/remove haben end_date NULL (API hat es
|
||||
# bisher genullt) und gelten damit unverändert unbegrenzt.
|
||||
op.add_column('scenario_modifiers', sa.Column('start_date', sa.Date(), nullable=True))
|
||||
op.add_column('scenario_planned_items',
|
||||
sa.Column('category_id', sa.Integer(), nullable=True))
|
||||
op.create_foreign_key(FK_PLANNED_CATEGORY, 'scenario_planned_items',
|
||||
'categories', ['category_id'], ['id'])
|
||||
# Batch-Modus: SQLite kennt kein ALTER von Constraints (Tabelle wird neu
|
||||
# angelegt); auf Postgres entspricht das den direkten ALTER-Befehlen.
|
||||
with op.batch_alter_table('scenario_planned_items') as batch:
|
||||
batch.add_column(sa.Column('category_id', sa.Integer(), nullable=True))
|
||||
batch.create_foreign_key(FK_PLANNED_CATEGORY, 'categories',
|
||||
['category_id'], ['id'])
|
||||
op.create_table(
|
||||
'scenario_recurring_items',
|
||||
sa.Column('id', sa.Integer(), primary_key=True),
|
||||
@@ -49,6 +51,6 @@ def downgrade() -> None:
|
||||
op.execute("UPDATE scenario_modifiers SET end_date = NULL WHERE kind <> 'ende'")
|
||||
op.drop_index('ix_scenario_recurring_items_scenario_id', 'scenario_recurring_items')
|
||||
op.drop_table('scenario_recurring_items')
|
||||
op.drop_constraint(FK_PLANNED_CATEGORY, 'scenario_planned_items', type_='foreignkey')
|
||||
op.drop_column('scenario_planned_items', 'category_id')
|
||||
with op.batch_alter_table('scenario_planned_items') as batch:
|
||||
batch.drop_column('category_id')
|
||||
op.drop_column('scenario_modifiers', 'start_date')
|
||||
|
||||
Reference in New Issue
Block a user