gate2: fix duplicate column/index in migrations for fresh DB installation
This commit is contained in:
@@ -30,11 +30,11 @@ depends_on = None
|
||||
|
||||
def upgrade() -> None:
|
||||
# 1. Add envelope columns to event_outbox
|
||||
op.add_column("event_outbox", sa.Column("aggregate_type", sa.String(100), nullable=True))
|
||||
op.add_column("event_outbox", sa.Column("aggregate_id", PGUUID(as_uuid=True), nullable=True))
|
||||
op.add_column("event_outbox", sa.Column("occurred_at", sa.DateTime(timezone=True), server_default=sa.text("NOW()"), nullable=False))
|
||||
op.add_column("event_outbox", sa.Column("correlation_id", PGUUID(as_uuid=True), nullable=True))
|
||||
op.add_column("event_outbox", sa.Column("schema_version", sa.Integer, nullable=False, server_default=sa.text("1")))
|
||||
op.execute("ALTER TABLE event_outbox ADD COLUMN IF NOT EXISTS aggregate_type VARCHAR(100)")
|
||||
op.execute("ALTER TABLE event_outbox ADD COLUMN IF NOT EXISTS aggregate_id UUID")
|
||||
op.execute("ALTER TABLE event_outbox ADD COLUMN IF NOT EXISTS occurred_at TIMESTAMPTZ NOT NULL DEFAULT NOW()")
|
||||
op.execute("ALTER TABLE event_outbox ADD COLUMN IF NOT EXISTS correlation_id UUID")
|
||||
op.execute("ALTER TABLE event_outbox ADD COLUMN IF NOT EXISTS schema_version INTEGER NOT NULL DEFAULT 1")
|
||||
|
||||
op.execute("CREATE INDEX IF NOT EXISTS ix_event_outbox_aggregate ON event_outbox (tenant_id, aggregate_type, aggregate_id)")
|
||||
op.execute("CREATE INDEX IF NOT EXISTS ix_event_outbox_correlation ON event_outbox (correlation_id)")
|
||||
|
||||
Reference in New Issue
Block a user