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 -10
View File
@@ -20,16 +20,8 @@ depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
op.add_column(
"users",
sa.Column(
"role_id",
postgresql.UUID(as_uuid=True),
sa.ForeignKey("roles.id", ondelete="SET NULL"),
nullable=True,
),
)
op.create_index("ix_users_role_id", "users", ["role_id"])
op.execute("ALTER TABLE users ADD COLUMN IF NOT EXISTS role_id UUID REFERENCES roles(id) ON DELETE SET NULL")
op.execute("CREATE INDEX IF NOT EXISTS ix_users_role_id ON users (role_id)")
def downgrade() -> None: