From 69473c4fbec7775cae2badfeb16990aa0e9e85a4 Mon Sep 17 00:00:00 2001 From: Fire Demon Date: Sun, 20 Sep 2020 03:37:04 -0500 Subject: [Feature] Community-managed custom emoji --- db/migrate/20200919234917_add_account_to_custom_emoji.rb | 7 +++++++ db/migrate/20200920084007_backfill_custom_emoji_ownership.rb | 12 ++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 db/migrate/20200919234917_add_account_to_custom_emoji.rb create mode 100644 db/migrate/20200920084007_backfill_custom_emoji_ownership.rb (limited to 'db/migrate') diff --git a/db/migrate/20200919234917_add_account_to_custom_emoji.rb b/db/migrate/20200919234917_add_account_to_custom_emoji.rb new file mode 100644 index 000000000..b4466ee30 --- /dev/null +++ b/db/migrate/20200919234917_add_account_to_custom_emoji.rb @@ -0,0 +1,7 @@ +class AddAccountToCustomEmoji < ActiveRecord::Migration[5.2] + def change + safety_assured do + add_reference :custom_emojis, :account, foreign_key: { on_delete: :nullify }, index: true + end + end +end diff --git a/db/migrate/20200920084007_backfill_custom_emoji_ownership.rb b/db/migrate/20200920084007_backfill_custom_emoji_ownership.rb new file mode 100644 index 000000000..1542bdb5e --- /dev/null +++ b/db/migrate/20200920084007_backfill_custom_emoji_ownership.rb @@ -0,0 +1,12 @@ +class BackfillCustomEmojiOwnership < ActiveRecord::Migration[5.2] + disable_ddl_transaction! + + def up + site_contact = Account.site_contact + CustomEmoji.local.in_batches.update_all(account_id: site_contact.id) + end + + def down + nil + end +end -- cgit