mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Promote historic post_deploy migrations (#25329)
This commit promotes all post_deploy migrations which existed in Discourse v3.1.0 (timestamp <= 20230405121454)
This commit is contained in:
@@ -1,11 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class DeleteOldRateLimitSearchAnon < ActiveRecord::Migration[7.0]
|
||||
def change
|
||||
execute "DELETE FROM site_settings WHERE name in ('rate_limit_search_anon_user', 'rate_limit_search_anon_global')"
|
||||
end
|
||||
|
||||
def down
|
||||
raise ActiveRecord::IrreversibleMigration
|
||||
end
|
||||
end
|
||||
@@ -1,22 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class TriggerPostRebakeLocalOneboxXss < ActiveRecord::Migration[7.0]
|
||||
def up
|
||||
val =
|
||||
DB.query_single(
|
||||
"SELECT value FROM site_settings WHERE name = 'content_security_policy'",
|
||||
).first
|
||||
|
||||
return if val == nil || val == "t"
|
||||
|
||||
DB.exec(<<~SQL)
|
||||
UPDATE posts
|
||||
SET baked_version = NULL
|
||||
WHERE cooked LIKE '%<a href=%'
|
||||
SQL
|
||||
end
|
||||
|
||||
def down
|
||||
raise ActiveRecord::IrreversibleMigration
|
||||
end
|
||||
end
|
||||
@@ -1,23 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ReindexInvalidIndexes < ActiveRecord::Migration[7.0]
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
invalid_index_names = DB.query_single(<<~SQL)
|
||||
SELECT
|
||||
pg_class.relname
|
||||
FROM pg_class, pg_index, pg_namespace
|
||||
WHERE pg_index.indisvalid = false
|
||||
AND pg_index.indexrelid = pg_class.oid
|
||||
AND pg_namespace.nspname = 'public'
|
||||
AND relnamespace = pg_namespace.oid;
|
||||
SQL
|
||||
|
||||
invalid_index_names.each { |index_name| execute "REINDEX INDEX CONCURRENTLY #{index_name}" }
|
||||
end
|
||||
|
||||
def down
|
||||
raise ActiveRecord::IrreversibleMigration
|
||||
end
|
||||
end
|
||||
@@ -1,14 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class DropInvalidDrafts < ActiveRecord::Migration[7.0]
|
||||
def up
|
||||
execute <<~SQL
|
||||
DELETE FROM drafts
|
||||
WHERE LENGTH(data) > 400000
|
||||
SQL
|
||||
end
|
||||
|
||||
def down
|
||||
raise ActiveRecord::IrreversibleMigration
|
||||
end
|
||||
end
|
||||
@@ -1,15 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "migration/column_dropper"
|
||||
|
||||
class RemoveTopicCountFromTags < ActiveRecord::Migration[7.0]
|
||||
DROPPED_COLUMNS ||= { tags: %i[topic_count] }
|
||||
|
||||
def up
|
||||
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }
|
||||
end
|
||||
|
||||
def down
|
||||
raise ActiveRecord::IrreversibleMigration
|
||||
end
|
||||
end
|
||||
@@ -1,17 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class DropOrphanedReviewableFlaggedPosts < ActiveRecord::Migration[7.0]
|
||||
def up
|
||||
DB.exec(<<~SQL)
|
||||
DELETE FROM reviewables
|
||||
WHERE reviewables.type = 'ReviewableFlaggedPost'
|
||||
AND reviewables.status = 0
|
||||
AND reviewables.target_type = 'Post'
|
||||
AND NOT EXISTS(SELECT 1 FROM posts WHERE posts.id = reviewables.target_id)
|
||||
SQL
|
||||
end
|
||||
|
||||
def down
|
||||
raise ActiveRecord::IrreversibleMigration
|
||||
end
|
||||
end
|
||||
@@ -1,9 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class BackfillSvgSprites < ActiveRecord::Migration[7.0]
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
ThemeSvgSprite.refetch!
|
||||
end
|
||||
end
|
||||
@@ -1,13 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class DropBadgeGrantedTitleColumn < ActiveRecord::Migration[7.0]
|
||||
DROPPED_COLUMNS ||= { user_profiles: %i[badge_granted_title] }
|
||||
|
||||
def up
|
||||
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }
|
||||
end
|
||||
|
||||
def down
|
||||
raise ActiveRecord::IrreversibleMigration
|
||||
end
|
||||
end
|
||||
@@ -1,17 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class UpdatePasswordAlgorithmPostDeploy < ActiveRecord::Migration[7.0]
|
||||
def up
|
||||
# Handles any users that were created by old-version app code since
|
||||
# the 20230405121453 pre-deploy migration was run
|
||||
execute <<~SQL
|
||||
UPDATE users SET password_algorithm = '$pbkdf2-sha256$i=64000,l=32$'
|
||||
WHERE users.password_algorithm IS NULL
|
||||
AND users.password_hash IS NOT NULL
|
||||
SQL
|
||||
end
|
||||
|
||||
def down
|
||||
raise ActiveRecord::IrreversibleMigration
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user