···11+-- The old insert path wrote for_account through without validating it
22+-- so an older row can contain any string at all
33+-- most often a handle or the literal 'admin' the column defaulted to
44+-- where the read path warns and drops whatever the Did newtype won't parse
55+-- so an unconverted row comes back with no for_account at all.
66+-- The first statement resolves the bare handles that still match a user
77+-- and the second covers every 'admin' row, since created_by_user is NOT NULL.
88+-- Nothing else converts
99+-- so a prefixed handle, a handle whose user has renamed since,
1010+-- and anything that was never an identifier all stay as they are.
1111+UPDATE invite_codes ic
1212+SET for_account = u.did
1313+FROM users u
1414+WHERE LOWER(u.handle) = LOWER(ic.for_account)
1515+ AND ic.for_account NOT LIKE 'did:%';
1616+1717+UPDATE invite_codes ic
1818+SET for_account = u.did
1919+FROM users u
2020+WHERE u.id = ic.created_by_user
2121+ AND ic.for_account = 'admin';