Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
SECURITY: update old username when the user is anonymized. (#55)
Previously, when a user is anonymized their new username is not updated in the yearly review topic.
- Loading branch information
1 parent
cb9a2df
commit b3ab33b
Showing
5 changed files
with
80 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
db/post_migrate/20230208123631_backfill_yearly_review_custom_fields.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| class BackfillYearlyReviewCustomFields < ActiveRecord::Migration[6.1] | ||
| def change | ||
| 2017.upto(2022) do |year| | ||
| topic_title = I18n.t("yearly_review.topic_title", year: year) | ||
| DB.exec( | ||
| <<~SQL, | ||
| INSERT INTO post_custom_fields (post_id, name, value, created_at, updated_at) | ||
| SELECT posts.id, :name, :value, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP | ||
| FROM posts | ||
| INNER JOIN topics ON topics.id = posts.topic_id | ||
| WHERE posts.user_id = :user_id AND topics.title = :title | ||
| ON CONFLICT DO NOTHING | ||
| SQL | ||
| title: topic_title, | ||
| user_id: Discourse::SYSTEM_USER_ID, | ||
| name: YearlyReview::POST_CUSTOM_FIELD, | ||
| value: year.to_s, | ||
| ) | ||
| end | ||
| end | ||
| end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters