-
-
Notifications
You must be signed in to change notification settings - Fork 7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make custom emoji domains case insensitive #9351 #9474
Conversation
@@ -0,0 +1,5 @@ | |||
class DowncaseCustomEmojiDomains < ActiveRecord::Migration[5.2] | |||
def change | |||
CustomEmoji.update_all('domain = lower(domain)') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use in_batches.update_all
to prevent table lock ups
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, I didn't know this existed!
@@ -0,0 +1,5 @@ | |||
class DowncaseCustomEmojiDomains < ActiveRecord::Migration[5.2] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add disable_ddl_transaction!
to use no locking around the updates.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I'm learning a lot about ActiveRecord migrations :)
db/schema.rb
Outdated
@@ -336,9 +336,9 @@ | |||
create_table "mutes", force: :cascade do |t| | |||
t.datetime "created_at", null: false | |||
t.datetime "updated_at", null: false | |||
t.boolean "hide_notifications", default: true, null: false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what this is about, the version string update is OK but this seems unnecessary, you can manually switch it around.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, this is the result of a bad merge. My bad for not seeing it!
Reverted
Also revert spurious schema change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Gargron - I've forgotten so much about rails!
@@ -0,0 +1,5 @@ | |||
class DowncaseCustomEmojiDomains < ActiveRecord::Migration[5.2] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I'm learning a lot about ActiveRecord migrations :)
@@ -0,0 +1,5 @@ | |||
class DowncaseCustomEmojiDomains < ActiveRecord::Migration[5.2] | |||
def change | |||
CustomEmoji.update_all('domain = lower(domain)') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, I didn't know this existed!
db/schema.rb
Outdated
@@ -336,9 +336,9 @@ | |||
create_table "mutes", force: :cascade do |t| | |||
t.datetime "created_at", null: false | |||
t.datetime "updated_at", null: false | |||
t.boolean "hide_notifications", default: true, null: false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, this is the result of a bad merge. My bad for not seeing it!
Reverted
* Make custom emoji domains case sensitive mastodon#9351 * Fixup style in downcase_domain to comply with codeclimate. * switch if! to unless * Don't use transactions, operate in batches. Also revert spurious schema change.
Make custom emoji domains case insensitive to fix #9531
Postgres supports CITEXT, but migrating the database from TEXT to CITEXT could require a whole table lock or an interim migration with dual writes.
Instead, it should be fine to migrate existing rows to lowercase one-by-one, input only lowercase input in future, and do comparisons against lowercase input.
This is my first pull request for mastodon and I haven't worked in Ruby in a long time - please let me know if I'm missing something!