Add a new column to the works table to store whether the work has comments disabled

Description

In order to allow users to disable comments for AO3-5897, the works table needs to be modified to add a new column. This column should have type tinyint, so that it can take on three different values:

  • 0 (enable_all) when all commenting on the work is enabled.

  • 1 (disable_anon) when anonymous commenting is disabled, but registered comments are enabled.

  • 2 (disable_all) when all commenting on the work is disabled.

There also needs to be a rake task to copy the existing value from anon_commenting_disabled to the new column.

(Note: From a migration perspective, it'd be easier to change the display width of the existing column and rename it, both of which are metadata-only changes and should be fairly instantaneous. But renaming columns with no downtime generally requires adding a copy of the column under the new name anyway, so we might as well change the type of the new column at the same time.)

Deploy Steps

  1. Run the migration to add the new column.

  2. Do a rolling restart of the unicorns to make sure that they know that the new column exists.

  3. Once all unicorns have finished restarting, run the rake task After:copy_anon_commenting_disabled_to_comment_permissions to copy the contents of anon_commenting_disabled to the new column.

Testing Instructions

  1. Find an old work that hasn't been edited since the deploy, with anonymous commenting disabled.

  2. Using the rails console, check the value of comment_permissions for that work. Make sure that it equals disable_anon.

  3. Edit the work to allow anonymous comments.

  4. Use the rails console, check the value of comment_permissions for that work. Make sure that it equals enable_all.

Activity

Show:
ticking instant
June 30, 2020, 7:28 PM

After poking around the rails source code, I think my mistake was in the deploy steps – the workers need to be restarted a second time after the migration has been run, but before the rake task has been run. And they need to be 100% finished restarting before the rake task runs.

(The development environment doesn’t really cache enough to accurately simulate the production environment in this case.)

james_
June 30, 2020, 10:21 PM
Edited
redsummernight
June 30, 2020, 11:29 PM
  1. Checked an old work with anonymous commenting disabled, before migration: https://test.archiveofourown.org/works/1071689. It had the correct properties:

  2. After migration + unicorn restarts + rake, edited the work to allow anonymous comments. Checked the console again, it had the correct properties:

  3. Just for fun, edited the work to disable anon comments again. Checked the console, still looked correct:

Looks good.

Sarken
July 1, 2020, 12:44 AM

Re-tested, and can confirm that this time, the comment_permissions came back "enable_all" after editing!

Sarken
August 9, 2020, 5:05 AM
Edited

From July 1:

james_ 05:45

05:47

05:48

05:51

james_ 05:59

05:59

now restart all the unicorns

james_ 08:51

DeployedToBeta

Assignee

ticking instant

Reporter

ticking instant

Roadmap

Works

Priority

Medium

Affects versions

Fix versions

Components

BackEnd

Difficulty

Medium

Milestone

Internal 0.9
Configure