about summary refs log tree commit diff
path: root/db/migrate
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2019-01-11 10:53:58 +0100
committerGitHub <noreply@github.com>2019-01-11 10:53:58 +0100
commit2cfa55185a5fc7d93a160a4e9a4730aae6725b0f (patch)
treec57169b5a3d717f4e68b8ec5d2d6e220d1456434 /db/migrate
parentd1da0a1086fa25f22739277fbf32ba1b3745317d (diff)
parent394525e32994e605093c87d3a9fad2a4202f3401 (diff)
Merge pull request #885 from ThibG/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'db/migrate')
-rw-r--r--db/migrate/20181207011115_downcase_custom_emoji_domains.rb10
-rw-r--r--db/migrate/20181226021420_add_also_known_as_to_accounts.rb5
-rw-r--r--db/migrate/20190103124649_create_scheduled_statuses.rb9
-rw-r--r--db/migrate/20190103124754_add_scheduled_status_id_to_media_attachments.rb8
4 files changed, 31 insertions, 1 deletions
diff --git a/db/migrate/20181207011115_downcase_custom_emoji_domains.rb b/db/migrate/20181207011115_downcase_custom_emoji_domains.rb
index c9db3800d..65f1fc8d9 100644
--- a/db/migrate/20181207011115_downcase_custom_emoji_domains.rb
+++ b/db/migrate/20181207011115_downcase_custom_emoji_domains.rb
@@ -1,7 +1,15 @@
 class DowncaseCustomEmojiDomains < ActiveRecord::Migration[5.2]
   disable_ddl_transaction!
 
-  def change
+  def up
+    duplicates = CustomEmoji.connection.select_all('SELECT string_agg(id::text, \',\') AS ids FROM custom_emojis GROUP BY shortcode, lower(domain) HAVING count(*) > 1').to_hash
+
+    duplicates.each do |row|
+      CustomEmoji.where(id: row['ids'].split(',')[0...-1]).destroy_all
+    end
+
     CustomEmoji.in_batches.update_all('domain = lower(domain)')
   end
+
+  def down; end
 end
diff --git a/db/migrate/20181226021420_add_also_known_as_to_accounts.rb b/db/migrate/20181226021420_add_also_known_as_to_accounts.rb
new file mode 100644
index 000000000..1fd956680
--- /dev/null
+++ b/db/migrate/20181226021420_add_also_known_as_to_accounts.rb
@@ -0,0 +1,5 @@
+class AddAlsoKnownAsToAccounts < ActiveRecord::Migration[5.2]
+  def change
+    add_column :accounts, :also_known_as, :string, array: true
+  end
+end
diff --git a/db/migrate/20190103124649_create_scheduled_statuses.rb b/db/migrate/20190103124649_create_scheduled_statuses.rb
new file mode 100644
index 000000000..2b78073b8
--- /dev/null
+++ b/db/migrate/20190103124649_create_scheduled_statuses.rb
@@ -0,0 +1,9 @@
+class CreateScheduledStatuses < ActiveRecord::Migration[5.2]
+  def change
+    create_table :scheduled_statuses do |t|
+      t.belongs_to :account, foreign_key: { on_delete: :cascade }
+      t.datetime :scheduled_at, index: true
+      t.jsonb :params
+    end
+  end
+end
diff --git a/db/migrate/20190103124754_add_scheduled_status_id_to_media_attachments.rb b/db/migrate/20190103124754_add_scheduled_status_id_to_media_attachments.rb
new file mode 100644
index 000000000..6f6cf2351
--- /dev/null
+++ b/db/migrate/20190103124754_add_scheduled_status_id_to_media_attachments.rb
@@ -0,0 +1,8 @@
+class AddScheduledStatusIdToMediaAttachments < ActiveRecord::Migration[5.2]
+  disable_ddl_transaction!
+
+  def change
+    add_reference :media_attachments, :scheduled_status, foreign_key: { on_delete: :nullify }, index: false
+    add_index :media_attachments, :scheduled_status_id, algorithm: :concurrently
+  end
+end