about summary refs log tree commit diff
path: root/db/migrate
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2021-05-07 18:21:59 +0200
committerClaire <claire.github-309c@sitedethib.com>2021-05-07 18:21:59 +0200
commit50b430d9a2857edf8ab44e9b94c7bcb14ecd2117 (patch)
tree4932ca1d8e52f6ce9b8b9fbb304b6bfce4027e54 /db/migrate
parenta346912030012dc1451249373ff7ef1a61016517 (diff)
parentd8e0c8a89e1f1dd1c4ce1513deaeb3c85c6e4a42 (diff)
Merge branch 'main' into glitch-soc/merge-upstream
- `app/views/statuses/_simple_status.html.haml`:
  Small markup change in glitch-soc, on a line that has been modified by
  upstream. Ported upstream changes.
Diffstat (limited to 'db/migrate')
-rw-r--r--db/migrate/20210322164601_create_account_summaries.rb2
-rw-r--r--db/migrate/20210421121431_add_case_insensitive_btree_index_to_tags.rb13
-rw-r--r--db/migrate/20210425135952_add_index_on_media_attachments_account_id_status_id.rb13
-rw-r--r--db/migrate/20210505174616_update_follow_recommendations_to_version_2.rb18
4 files changed, 45 insertions, 1 deletions
diff --git a/db/migrate/20210322164601_create_account_summaries.rb b/db/migrate/20210322164601_create_account_summaries.rb
index b9faf180d..bc9011113 100644
--- a/db/migrate/20210322164601_create_account_summaries.rb
+++ b/db/migrate/20210322164601_create_account_summaries.rb
@@ -1,6 +1,6 @@
 class CreateAccountSummaries < ActiveRecord::Migration[5.2]
   def change
-    create_view :account_summaries, materialized: true
+    create_view :account_summaries, materialized: { no_data: true }
 
     # To be able to refresh the view concurrently,
     # at least one unique index is required
diff --git a/db/migrate/20210421121431_add_case_insensitive_btree_index_to_tags.rb b/db/migrate/20210421121431_add_case_insensitive_btree_index_to_tags.rb
new file mode 100644
index 000000000..ed359e8cd
--- /dev/null
+++ b/db/migrate/20210421121431_add_case_insensitive_btree_index_to_tags.rb
@@ -0,0 +1,13 @@
+class AddCaseInsensitiveBtreeIndexToTags < ActiveRecord::Migration[5.2]
+  disable_ddl_transaction!
+
+  def up
+    safety_assured { execute 'CREATE UNIQUE INDEX CONCURRENTLY index_tags_on_name_lower_btree ON tags (lower(name) text_pattern_ops)' }
+    remove_index :tags, name: 'index_tags_on_name_lower'
+  end
+
+  def down
+    safety_assured { execute 'CREATE UNIQUE INDEX CONCURRENTLY index_tags_on_name_lower ON tags (lower(name))' }
+    remove_index :tags, name: 'index_tags_on_name_lower_btree'
+  end
+end
diff --git a/db/migrate/20210425135952_add_index_on_media_attachments_account_id_status_id.rb b/db/migrate/20210425135952_add_index_on_media_attachments_account_id_status_id.rb
new file mode 100644
index 000000000..5ef2d3c39
--- /dev/null
+++ b/db/migrate/20210425135952_add_index_on_media_attachments_account_id_status_id.rb
@@ -0,0 +1,13 @@
+class AddIndexOnMediaAttachmentsAccountIdStatusId < ActiveRecord::Migration[5.2]
+  disable_ddl_transaction!
+
+  def up
+    add_index :media_attachments, [:account_id, :status_id], order: { status_id: :desc }, algorithm: :concurrently
+    remove_index :media_attachments, :account_id, algorithm: :concurrently
+  end
+
+  def down
+    add_index :media_attachments, :account_id, algorithm: :concurrently
+    remove_index :media_attachments, [:account_id, :status_id], order: { status_id: :desc }, algorithm: :concurrently
+  end
+end
diff --git a/db/migrate/20210505174616_update_follow_recommendations_to_version_2.rb b/db/migrate/20210505174616_update_follow_recommendations_to_version_2.rb
new file mode 100644
index 000000000..56c0b4cb0
--- /dev/null
+++ b/db/migrate/20210505174616_update_follow_recommendations_to_version_2.rb
@@ -0,0 +1,18 @@
+class UpdateFollowRecommendationsToVersion2 < ActiveRecord::Migration[6.1]
+  # We're switching from a normal to a materialized view so we need
+  # custom `up` and `down` paths.
+
+  def up
+    drop_view :follow_recommendations
+    create_view :follow_recommendations, version: 2, materialized: { no_data: true }
+
+    # To be able to refresh the view concurrently,
+    # at least one unique index is required
+    safety_assured { add_index :follow_recommendations, :account_id, unique: true }
+  end
+
+  def down
+    drop_view :follow_recommendations, materialized: true
+    create_view :follow_recommendations, version: 1
+  end
+end