fix: make migrations idempotent with if_not_exists
Add if_not_exists=True to CREATE TABLE operations in migrations 0003 and 0004. This prevents DuplicateTableError when migrations are re-run on databases where tables were partially created.
This commit is contained in:
@@ -27,7 +27,8 @@ def upgrade() -> None:
|
||||
sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('user_id')
|
||||
sa.UniqueConstraint('user_id'),
|
||||
if_not_exists=True,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ def upgrade() -> None:
|
||||
onupdate=sa.text("now()"),
|
||||
nullable=False,
|
||||
),
|
||||
if_not_exists=True,
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user