Skip to content

Commit

Permalink
update migration to strip kid prefixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Puyodead1 committed Aug 1, 2024
1 parent 0772455 commit fb53815
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions alembic/versions/f3df682d6393_add_id_to_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ def upgrade() -> None:
sa.PrimaryKeyConstraint("id"),
)

# Copy data from the old table to the new table, setting added_by to NULL for invalid references
# Copy data from the old table to the new table, setting added_by to NULL for invalid references, and strip the kid prefix
op.execute(
"INSERT INTO keys_ (kid, added_at, added_by, license_url, key_) "
"SELECT kid, added_at, CASE WHEN added_by IN (SELECT id FROM users) THEN added_by ELSE NULL END, license_url, key_ FROM keys_old"
"SELECT kid, added_at, CASE WHEN added_by IN (SELECT id FROM users) THEN added_by ELSE NULL END, license_url, split_part(key_, ':', 2) FROM keys_old"
)

# Drop the old table
Expand Down

0 comments on commit fb53815

Please sign in to comment.