Skip to content

Commit

Permalink
Ensure patron uuid are set in the migration.
Browse files Browse the repository at this point in the history
  • Loading branch information
dbernstein committed Oct 31, 2024
1 parent ebd6826 commit bc796d7
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions alembic/versions/20241030_272da5f400de_add_uuid_to_patron_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,22 @@ def upgrade() -> None:
sa.Column("uuid", UUID(as_uuid=True), nullable=False, default=uuid.uuid4),
)

conn = op.get_bind()
rows = conn.execute("SELECT id from patrons").all()

for row in rows:
conn.execute(
"""
UPDATE patrons
SET uuid = %(uuid)s
WHERE id = %(id)s
""",
{
"id": row.id,
"uuid": uuid.uuid4(),
},
)


def downgrade() -> None:
op.drop_column("patrons", "uuid")

0 comments on commit bc796d7

Please sign in to comment.