gate2: fix duplicate column/index in migrations for fresh DB installation

This commit is contained in:
Agent Zero
2026-07-31 18:20:09 +02:00
parent 224a5ea9af
commit dd7ad461d8
17 changed files with 53 additions and 78 deletions
+2 -14
View File
@@ -20,20 +20,8 @@ depends_on = None
def upgrade():
op.add_column(
"mail_accounts",
sa.Column(
"owner_id",
UUID(as_uuid=True),
sa.ForeignKey("users.id", ondelete="SET NULL"),
nullable=True,
),
)
op.create_index(
"ix_mail_accounts_owner",
"mail_accounts",
["owner_id"],
)
op.execute("ALTER TABLE mail_accounts ADD COLUMN IF NOT EXISTS owner_id UUID REFERENCES users(id) ON DELETE SET NULL")
op.execute("CREATE INDEX IF NOT EXISTS ix_mail_accounts_owner ON mail_accounts (owner_id)")
def downgrade():