gate2: fix all migrations for fresh DB installation
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user