From 36dec61652441cb7706faf57670ef2750fd18567 Mon Sep 17 00:00:00 2001 From: Daniel Grittner Date: Tue, 5 Nov 2024 13:03:49 +0100 Subject: [PATCH] fix: secret type migration --- ...cf73c0869_migrate_secrets_to_secret_type.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/admyral/db/alembic/versions/db5cf73c0869_migrate_secrets_to_secret_type.py b/admyral/db/alembic/versions/db5cf73c0869_migrate_secrets_to_secret_type.py index 83452eda..a4851ae4 100644 --- a/admyral/db/alembic/versions/db5cf73c0869_migrate_secrets_to_secret_type.py +++ b/admyral/db/alembic/versions/db5cf73c0869_migrate_secrets_to_secret_type.py @@ -22,6 +22,8 @@ def upgrade() -> None: # ### commands auto generated by Alembic - please adjust! ### + bind = op.get_bind() + integrations = [ ("anthropic", "Anthropic"), ("mistral ai", "Mistral AI"), @@ -57,17 +59,21 @@ def upgrade() -> None: for potential_name, secret_type in integrations: potential_name: str = potential_name.lower() - op.execute( - "UPDATE secrets SET secret_type = :new_type WHERE secret_type LIKE :pattern", - execution_options={ + bind.execute( + sqlmodel.text( + "UPDATE secrets SET secret_type = :new_type WHERE secret_type LIKE :pattern" + ), + { "new_type": secret_type, "pattern": f"%{potential_name}%", }, ) potential_name = potential_name.replace(" ", "_") - op.execute( - "UPDATE secrets SET secret_type = :new_type WHERE secret_type LIKE :pattern", - execution_options={ + bind.execute( + sqlmodel.text( + "UPDATE secrets SET secret_type = :new_type WHERE secret_type LIKE :pattern" + ), + { "new_type": secret_type, "pattern": f"%{potential_name}%", },