Skip to content

Commit

Permalink
fixup! update SQLAlchemy from 1.4 to 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mvalik committed May 29, 2023
1 parent 6f2bbfc commit 5947bbb
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@
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 connection.execute('SELECT id, subject FROM waiver'):
for row in db.session.execute(text('SELECT id, subject FROM waiver')):
fixed_subject = json_serializer(json.loads(row['subject']))
connection.execute(text('UPDATE waiver SET subject = :subject WHERE id = :id'),
db.session.execute(text('UPDATE waiver SET subject = :subject WHERE id = :id'),
subject=fixed_subject, id=row['id'])

op.drop_index('ix_waiver_subject')
Expand Down

0 comments on commit 5947bbb

Please sign in to comment.