Migrate remaining U2fRegistration to WebauthnRegistration
What does this MR do and why?
The migration in this MR has been copied over from a migration that existed earlier from !46179 (merged).
Why are we running this migration again?
We noticed that 70 U2fRegistrations
records have not been migrated to WebauthnRegistration
records as expected, so we need to have post deployment migration that fixes this problem and creates 70 new WebauthnRegistration
records.
Why were these 70 records never created?
We noticed that 64 out of these 70 records had an ActiveModel validation that was throwing error while being created via the after_create
callback on U2fRegistration
.
We fixed this problem a few days ago with !74376 (merged) and it has been deployed.
For the remaining 6 records, we could not find any associated problems and our finding is that we must have lost the background jobs that were supposed to create these records (or that these jobs errored out). The details about this finding are here.
So, now that we have fixed the root causes of the problem associated with these 70 records, we can execute the post deployment migration again that will complete our data migration from U2fRegistration
to WebauthnRegistration
.
Migrations
Up migration
$ rake db:migrate:up VERSION=20211117084814
== 20211117084814 MigrateRemainingU2fRegistrations: migrating =================
== 20211117084814 MigrateRemainingU2fRegistrations: migrated (0.0418s) ========
Down migration
$ rake db:migrate:down VERSION=20211117084814
== 20211117084814 MigrateRemainingU2fRegistrations: reverting =================
== 20211117084814 MigrateRemainingU2fRegistrations: reverted (0.0000s) ========
SQL query details:
Finding first element of the batch:
SELECT
"u2f_registrations"."id"
FROM
"u2f_registrations"
LEFT JOIN
webauthn_registrations
ON webauthn_registrations.u2f_registration_id = u2f_registrations.id
WHERE
"webauthn_registrations"."u2f_registration_id" IS NULL
ORDER BY
"u2f_registrations"."id" ASC LIMIT 1
https://console.postgres.ai/shared/f84776c6-b711-4907-a4fe-1f5d242c8704
Finding last element of the batch:
SELECT
"u2f_registrations"."id"
FROM
"u2f_registrations"
LEFT JOIN
webauthn_registrations
ON webauthn_registrations.u2f_registration_id = u2f_registrations.id
WHERE
"webauthn_registrations"."u2f_registration_id" IS NULL
AND "u2f_registrations"."id" >= 142171
ORDER BY
"u2f_registrations"."id" ASC LIMIT 1 OFFSET 100
https://console.postgres.ai/shared/2855d9e3-b477-4d69-ae5b-5ea13e341acc
Finding the whole batch:
SELECT
"u2f_registrations".*
FROM
"u2f_registrations"
LEFT JOIN
webauthn_registrations
ON webauthn_registrations.u2f_registration_id = u2f_registrations.id
WHERE
"webauthn_registrations"."u2f_registration_id" IS NULL
AND "u2f_registrations"."id" >= 142171
https://console.postgres.ai/shared/b726b11f-0007-4994-9e01-c9081c57fd2d
Screenshots or screen recordings
These are strongly recommended to assist reviewers and reduce the time to merge your change.
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.