DEV: Promote historic post_deploy migrations

DEV: Promote historic post_deploy migrations

This commit promotes all post_deploy migrations which existed in Discourse v2.6.7 (timestamp <= 20201110110952)

diff --git a/db/migrate/20200715045152_remove_bookmarks_delete_when_reminder_sent.rb b/db/migrate/20200715045152_remove_bookmarks_delete_when_reminder_sent.rb
new file mode 100644
index 0000000..7f4db8a
--- /dev/null
+++ b/db/migrate/20200715045152_remove_bookmarks_delete_when_reminder_sent.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class RemoveBookmarksDeleteWhenReminderSent < ActiveRecord::Migration[6.0]
+  def up
+    remove_column :bookmarks, :delete_when_reminder_sent
+  end
+
+  def down
+    add_column :bookmarks, :delete_when_reminder_sent, :boolean, default: false
+  end
+end
diff --git a/db/migrate/20200724060632_remove_deprecated_allowlist_settings.rb b/db/migrate/20200724060632_remove_deprecated_allowlist_settings.rb
new file mode 100644
index 0000000..38b87c9
--- /dev/null
+++ b/db/migrate/20200724060632_remove_deprecated_allowlist_settings.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+class RemoveDeprecatedAllowlistSettings < ActiveRecord::Migration[6.0]
+  def up
+    SiteSetting::ALLOWLIST_DEPRECATED_SITE_SETTINGS.each_pair do |old_key, _new_key|
+      DB.exec <<~SQL
+        DELETE FROM site_settings
+        WHERE name = '#{old_key}'
+      SQL
+    end
+  end
+
+  def down
+    SiteSetting::ALLOWLIST_DEPRECATED_SITE_SETTINGS.each_pair do |old_key, new_key|
+      DB.exec <<~SQL
+        INSERT INTO site_settings(name, data_type, value, created_at, updated_at)
+        SELECT '#{old_key}', data_type, value, created_at, updated_At
+        FROM site_settings
+        WHERE name = '#{new_key}'
+      SQL
+    end
+  end
+end
diff --git a/db/migrate/20200728004302_drop_path_whitelist_from_embeddable_hosts.rb b/db/migrate/20200728004302_drop_path_whitelist_from_embeddable_hosts.rb
new file mode 100644
index 0000000..56771b4
--- /dev/null
+++ b/db/migrate/20200728004302_drop_path_whitelist_from_embeddable_hosts.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class DropPathWhitelistFromEmbeddableHosts < ActiveRecord::Migration[6.0]
+  DROPPED_COLUMNS ||= {
+    embeddable_hosts: %i{path_whitelist}
+  }
+
+  def up
+    DROPPED_COLUMNS.each do |table, columns|
+      Migration::ColumnDropper.execute_drop(table, columns)
+    end
+  end
+
+  def down
+    add_column :embeddable_hosts, :path_whitelist, :string
+  end
+end
diff --git a/db/migrate/20200818084329_update_private_message_on_post_search_data.rb b/db/migrate/20200818084329_update_private_message_on_post_search_data.rb
new file mode 100644
index 0000000..cab2c49
--- /dev/null
+++ b/db/migrate/20200818084329_update_private_message_on_post_search_data.rb
@@ -0,0 +1,70 @@
+# frozen_string_literal: true
+
+class UpdatePrivateMessageOnPostSearchData < ActiveRecord::Migration[6.0]
+  # this is a very big change ... avoid an enormous transaction here
+  disable_ddl_transaction!
+
+  def update_private_message_flag
+
+    sql = <<~SQL
+      UPDATE post_search_data
+      SET private_message = X.private_message
+      FROM
+      (
+        SELECT post_id,
+          CASE WHEN t.archetype = 'private_message' THEN TRUE ELSE FALSE END private_message
+        FROM posts p
+        JOIN post_search_data pd ON pd.post_id = p.id
+        JOIN topics t ON t.id = p.topic_id
+        WHERE pd.private_message IS NULL OR
+          pd.private_message <> CASE WHEN t.archetype = 'private_message' THEN TRUE ELSE FALSE END
+        LIMIT 3000000
+      ) X
+      WHERE X.post_id = post_search_data.post_id
+    SQL
+
+    while true
+      count = execute(sql).cmd_tuples
+      if count == 0
+        break
+      else
+        puts "Migrated batch of #{count} on post_search_date to new schema"
+      end
+    end
+  end
+
+  def up
+    # Delete post_search_data of orphaned posts
+    execute <<~SQL
+    DELETE FROM post_search_data
+    WHERE post_id IN (
+      SELECT posts.id
+      FROM posts
+      LEFT JOIN topics ON topics.id = posts.topic_id
+      WHERE topics.id IS NULL
+    )
+    SQL
+
+    # Delete orphaned post_search_data
+    execute <<~SQL
+    DELETE FROM post_search_data
+    WHERE post_id IN (
+      SELECT post_search_data.post_id
+      FROM post_search_data
+      LEFT JOIN posts ON posts.id = post_search_data.post_id
+      WHERE posts.id IS NULL
+    )
+    SQL
+
+    update_private_message_flag
+
+    ActiveRecord::Base.transaction do
+      update_private_message_flag
+      change_column_null(:post_search_data, :private_message, false)
+    end
+  end
+
+  def down
+    raise ActiveRecord::IrreversibleMigration
+  end
+end
diff --git a/db/migrate/20200903045539_add_index_topics_on_timestamps_private.rb b/db/migrate/20200903045539_add_index_topics_on_timestamps_private.rb
new file mode 100644
index 0000000..9479dce
--- /dev/null
+++ b/db/migrate/20200903045539_add_index_topics_on_timestamps_private.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class AddIndexTopicsOnTimestampsPrivate < ActiveRecord::Migration[6.0]
+  disable_ddl_transaction!
+
+  def up
+    execute <<~SQL
+    CREATE INDEX CONCURRENTLY IF NOT EXISTS
+    index_topics_on_timestamps_private
+    ON topics (bumped_at, created_at, updated_at)
+    WHERE deleted_at IS NULL AND archetype = 'private_message'
+    SQL
+  end
+
+  def down
+    raise ActiveRecord::IrreversibleMigration
+  end
+end
diff --git a/db/migrate/20201110110952_drop_github_user_infos.rb b/db/migrate/20201110110952_drop_github_user_infos.rb
new file mode 100644
index 0000000..7fbbb78
--- /dev/null
+++ b/db/migrate/20201110110952_drop_github_user_infos.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+require 'migration/table_dropper'
+
+class DropGithubUserInfos < ActiveRecord::Migration[6.0]
+  DROPPED_TABLES ||= %i{ github_user_infos }
+
+  def up
+    DROPPED_TABLES.each do |table|
+      Migration::TableDropper.execute_drop(table)
+    end
+  end
+
+  def down
+    raise ActiveRecord::IrreversibleMigration
+  end
+end
diff --git a/db/post_migrate/20200715045152_remove_bookmarks_delete_when_reminder_sent.rb b/db/post_migrate/20200715045152_remove_bookmarks_delete_when_reminder_sent.rb
deleted file mode 100644
index 7f4db8a..0000000
--- a/db/post_migrate/20200715045152_remove_bookmarks_delete_when_reminder_sent.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-# frozen_string_literal: true
-
-class RemoveBookmarksDeleteWhenReminderSent < ActiveRecord::Migration[6.0]
-  def up
-    remove_column :bookmarks, :delete_when_reminder_sent
-  end
-
-  def down
-    add_column :bookmarks, :delete_when_reminder_sent, :boolean, default: false
-  end
-end
diff --git a/db/post_migrate/20200724060632_remove_deprecated_allowlist_settings.rb b/db/post_migrate/20200724060632_remove_deprecated_allowlist_settings.rb
deleted file mode 100644
index 38b87c9..0000000
--- a/db/post_migrate/20200724060632_remove_deprecated_allowlist_settings.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-# frozen_string_literal: true
-
-class RemoveDeprecatedAllowlistSettings < ActiveRecord::Migration[6.0]
-  def up
-    SiteSetting::ALLOWLIST_DEPRECATED_SITE_SETTINGS.each_pair do |old_key, _new_key|
-      DB.exec <<~SQL
-        DELETE FROM site_settings
-        WHERE name = '#{old_key}'
-      SQL
-    end
-  end
-
-  def down
-    SiteSetting::ALLOWLIST_DEPRECATED_SITE_SETTINGS.each_pair do |old_key, new_key|
-      DB.exec <<~SQL
-        INSERT INTO site_settings(name, data_type, value, created_at, updated_at)
-        SELECT '#{old_key}', data_type, value, created_at, updated_At
-        FROM site_settings
-        WHERE name = '#{new_key}'
-      SQL
-    end
-  end
-end
diff --git a/db/post_migrate/20200728004302_drop_path_whitelist_from_embeddable_hosts.rb b/db/post_migrate/20200728004302_drop_path_whitelist_from_embeddable_hosts.rb
deleted file mode 100644
index 56771b4..0000000
--- a/db/post_migrate/20200728004302_drop_path_whitelist_from_embeddable_hosts.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-# frozen_string_literal: true
-
-class DropPathWhitelistFromEmbeddableHosts < ActiveRecord::Migration[6.0]
-  DROPPED_COLUMNS ||= {

[... diff too long, it was truncated ...]

GitHub sha: 5968dc07a54a30bc4aa03e3ebdac8d2ce18f785f

This commit appears in #13496 which was approved by CvX. It was merged by davidtaylorhq.