From 876fae4c7b674c97f5cba8b2b85dae22bc7d53be Mon Sep 17 00:00:00 2001 From: Lukas Holecek Date: Jun 06 2023 14:02:41 +0000 Subject: Fix DB migrations (#88) --- diff --git a/waiverdb/migrations/versions/ce8a1351ecdc_change_subject_to_json.py b/waiverdb/migrations/versions/ce8a1351ecdc_change_subject_to_json.py index d208944..18c5764 100644 --- a/waiverdb/migrations/versions/ce8a1351ecdc_change_subject_to_json.py +++ b/waiverdb/migrations/versions/ce8a1351ecdc_change_subject_to_json.py @@ -15,16 +15,15 @@ from alembic import op from sqlalchemy import Text, text from sqlalchemy.dialects.postgresql import JSON from waiverdb.models.base import json_serializer -from waiverdb.models import db def upgrade(): # Re-serialize all subject values to ensure they match the new, consistent # serialization we are using. connection = op.get_bind() - for row in db.session.execute(text('SELECT id, subject FROM waiver')): + for row in connection.execute(text('SELECT id, subject FROM waiver')): fixed_subject = json_serializer(json.loads(row['subject'])) - db.session.execute(text('UPDATE waiver SET subject = :subject WHERE id = :id'), + connection.execute(text('UPDATE waiver SET subject = :subject WHERE id = :id'), subject=fixed_subject, id=row['id']) op.drop_index('ix_waiver_subject')