forked from mastodon/mastodon
-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#842 カスタム絵文字を利用した絵文字リアクションの他サーバーからの受け入れにおいて、カスタム絵文字のuriだけ指定されたActivit…
…yに対応する
- Loading branch information
Showing
5 changed files
with
92 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# frozen_string_literal: true | ||
|
||
class AddCustomEmojiIndex < ActiveRecord::Migration[7.1] | ||
disable_ddl_transaction! | ||
|
||
class CustomEmoji < ApplicationRecord | ||
end | ||
|
||
def up | ||
duplications = CustomEmoji.where('uri IN (SELECT uri FROM custom_emojis GROUP BY uri HAVING COUNT(*) > 1)') | ||
.to_a.group_by(&:uri).to_h | ||
|
||
if duplications.any? | ||
CustomEmoji.transaction do | ||
duplications.each do |h| | ||
h[1].drop(1).each(&:destroy) | ||
end | ||
end | ||
end | ||
|
||
add_index :custom_emojis, :uri, unique: true, algorithm: :concurrently | ||
end | ||
|
||
def down | ||
remove_index :custom_emojis, :uri | ||
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
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