This is the one prophesied to take down the site. Migration:
Change the primary key type from INT to BIGINT.
Add unique index for commentable_id + commentable_type + user_id. This will remove duplicate kudos for the same work from the same user.
Add unique index for commentable_id + commentable_type + ip_address. This will remove duplicate kudos for the same work from the same guest IP.
The migration will be different depending on the environment:
Add a usual Rails migration, to be used in dev and CI environments.
Add a comment with the pt-online-schema-change command to be run on staging and beta (similar to ).
How to test:
(Anyone) Test first.
(Server admin) Test the migration:
Run the migration.
Copy the commands that it prints to a file.
Run the pt-online-schema-change command, but not any of the SQL commands that follow it.
Create a brand new kudos, and note the ID in the database.
Create another kudos on the same work, from the same user (by using the Rails console and skipping validation, .save(validate: false)). This is a duplicate of the kudos from the previous step.
Run the SQL commands. (RENAME TABLE, DROP TRIGGER, and DROP TABLE)
Check whether the kudos that you created is still there. Check that it has no duplicates (the duplicates should have been eaten by the pt-online-schema-change migration).
From the Rails console: try to insert a duplicate kudos, bypassing validations, and make sure that it generates an error.
(Server admin) Test that the migration can run up and down and up again.
(Anyone) Finally, in the post-migration world:
Check that leaving logged in kudos still works.
Check that leaving logged in kudos a second time on the same work will get you the "left kudos here " message.
Check that you can no longer leave logged in kudos after changing default pseuds.