gate2: fix all migrations for fresh DB installation

This commit is contained in:
Agent Zero
2026-07-31 19:16:11 +02:00
parent d37388423d
commit 010ef448e7
40 changed files with 230 additions and 207 deletions
+5 -1
View File
@@ -32,9 +32,13 @@ def _column_exists(table: str, column: str) -> str:
def upgrade() -> None:
conn = op.get_bind()
# Check if table exists first
table_exists = conn.execute(sa.text("SELECT 1 FROM information_schema.tables WHERE table_name = 'files'")).fetchone()
if table_exists is None:
return
result = conn.execute(sa.text(_column_exists("files", "content_hash"))).fetchone()
if result is None:
op.add_column("files", sa.Column("content_hash", sa.String(64), nullable=True))
op.execute("ALTER TABLE files ADD COLUMN IF NOT EXISTS content_hash VARCHAR(64)")
def downgrade() -> None: