Something went wrong. Try again.
A downstream fork of Tranquil PDS for use in margin.cafe
Something went wrong. Try again.
908 B · 21 lines
SQL
12345678910111213141516171819202122-- The old insert path wrote for_account through without validating it-- so an older row can contain any string at all-- most often a handle or the literal 'admin' the column defaulted to-- where the read path warns and drops whatever the Did newtype won't parse-- so an unconverted row comes back with no for_account at all.-- The first statement resolves the bare handles that still match a user-- and the second covers every 'admin' row, since created_by_user is NOT NULL.-- Nothing else converts-- so a prefixed handle, a handle whose user has renamed since,-- and anything that was never an identifier all stay as they are.UPDATE invite_codes icSET for_account = u.didFROM users uWHERE LOWER(u.handle) = LOWER(ic.for_account) AND ic.for_account NOT LIKE 'did:%';
UPDATE invite_codes icSET for_account = u.didFROM users uWHERE u.id = ic.created_by_user AND ic.for_account = 'admin';