bifroest/app/migrations/versions/0021_database_engines.py
2026-10-27 08:34:17 +01:00

27 lines
931 B
Python

"""Quellenart Datenbank mit Typ (PostgreSQL, Oracle) statt postgres
Revision ID: 0021
Revises: 0020
Erstellt: 2026-10-25 11:20:00
"""
from alembic import op
revision = '0021'
down_revision = '0020'
branch_labels = None
depends_on = None
def upgrade() -> None:
op.execute("UPDATE data_sources SET kind = 'database', "
"config = (config::jsonb || '{\"engine\": \"postgres\"}'::jsonb)::json WHERE kind = 'postgres'")
op.execute("UPDATE tool_definitions SET kind = 'database' WHERE kind = 'postgres'")
def downgrade() -> None:
# Oracle-Quellen gibt es vorher nicht; sie bleiben als Art database stehen und werden ignoriert
op.execute("UPDATE data_sources SET kind = 'postgres', config = (config::jsonb - 'engine')::json "
"WHERE kind = 'database' AND config::jsonb ->> 'engine' = 'postgres'")
op.execute("UPDATE tool_definitions SET kind = 'postgres' WHERE kind = 'database'")