Phase 1-3 of decoupling plan: - Shared DB, models, infrastructure, browser, config, utils - Event infrastructure (domain_events outbox, bus, processor) - Structured logging - Generic container concept (container_type/container_id) - Alembic migrations for all schema changes Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
51 lines
1.2 KiB
Python
51 lines
1.2 KiB
Python
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
revision = "0007_add_oid_entries"
|
|
down_revision = "0006_update_calendar_entries"
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade():
|
|
# Add order_id column
|
|
op.add_column(
|
|
"calendar_entries",
|
|
sa.Column("order_id", sa.Integer(), nullable=True),
|
|
)
|
|
op.create_foreign_key(
|
|
"fk_calendar_entries_order_id",
|
|
"calendar_entries",
|
|
"orders",
|
|
["order_id"],
|
|
["id"],
|
|
ondelete="SET NULL",
|
|
)
|
|
op.create_index(
|
|
"ix_calendar_entries_order_id",
|
|
"calendar_entries",
|
|
["order_id"],
|
|
unique=False,
|
|
)
|
|
|
|
# Optional: add an index on state if you want faster queries by state
|
|
op.create_index(
|
|
"ix_calendar_entries_state",
|
|
"calendar_entries",
|
|
["state"],
|
|
unique=False,
|
|
)
|
|
|
|
|
|
def downgrade():
|
|
# Drop indexes and FK in reverse order
|
|
op.drop_index("ix_calendar_entries_state", table_name="calendar_entries")
|
|
|
|
op.drop_index("ix_calendar_entries_order_id", table_name="calendar_entries")
|
|
op.drop_constraint(
|
|
"fk_calendar_entries_order_id",
|
|
"calendar_entries",
|
|
type_="foreignkey",
|
|
)
|
|
op.drop_column("calendar_entries", "order_id")
|