mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Apply syntax_tree formatting to db/*
This commit is contained in:
@@ -2,14 +2,13 @@
|
||||
|
||||
class ResetCustomEmojiPostBakesVersionSecureFix < ActiveRecord::Migration[6.1]
|
||||
def up
|
||||
secure_media_enabled = DB.query_single("SELECT value FROM site_settings WHERE name = 'secure_media'")
|
||||
secure_media_enabled =
|
||||
DB.query_single("SELECT value FROM site_settings WHERE name = 'secure_media'")
|
||||
|
||||
if secure_media_enabled.present? && secure_media_enabled[0] == "t"
|
||||
execute <<~SQL
|
||||
execute <<~SQL if secure_media_enabled.present? && secure_media_enabled[0] == "t"
|
||||
UPDATE posts SET baked_version = 0
|
||||
WHERE cooked LIKE '%emoji emoji-custom%' AND cooked LIKE '%secure-media-uploads%'
|
||||
SQL
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
|
||||
@@ -16,12 +16,10 @@ class RebakeOldAvatarServiceUrls < ActiveRecord::Migration[6.1]
|
||||
AND created_at > NOW() - INTERVAL '1 month'
|
||||
SQL
|
||||
|
||||
if recently_changed
|
||||
execute <<~SQL
|
||||
execute <<~SQL if recently_changed
|
||||
UPDATE posts SET baked_version = 0
|
||||
WHERE cooked LIKE '%avatars.discourse.org%'
|
||||
SQL
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
|
||||
@@ -10,7 +10,9 @@ class MakeSomeBookmarkColumnsNullable < ActiveRecord::Migration[6.1]
|
||||
|
||||
def down
|
||||
DB.exec("UPDATE bookmarks SET post_id = bookmarkable_id WHERE bookmarkable_type = 'Post'")
|
||||
DB.exec("UPDATE bookmarks SET post_id = (SELECT id FROM posts WHERE topic_id = bookmarkable_id AND post_number = 1), for_topic = TRUE WHERE bookmarkable_type = 'Topic'")
|
||||
DB.exec(
|
||||
"UPDATE bookmarks SET post_id = (SELECT id FROM posts WHERE topic_id = bookmarkable_id AND post_number = 1), for_topic = TRUE WHERE bookmarkable_type = 'Topic'",
|
||||
)
|
||||
change_column_null :bookmarks, :post_id, false
|
||||
execute "ALTER TABLE bookmarks DROP CONSTRAINT enforce_post_id_or_bookmarkable"
|
||||
end
|
||||
|
||||
@@ -1,17 +1,10 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class DropCategoryRequiredTagGroupColumns < ActiveRecord::Migration[6.1]
|
||||
DROPPED_COLUMNS ||= {
|
||||
categories: %i{
|
||||
required_tag_group_id
|
||||
min_tags_from_required_group
|
||||
}
|
||||
}
|
||||
DROPPED_COLUMNS ||= { categories: %i[required_tag_group_id min_tags_from_required_group] }
|
||||
|
||||
def up
|
||||
DROPPED_COLUMNS.each do |table, columns|
|
||||
Migration::ColumnDropper.execute_drop(table, columns)
|
||||
end
|
||||
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }
|
||||
end
|
||||
|
||||
def down
|
||||
|
||||
@@ -1,14 +1,10 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class DropFlairUrlFromGroups < ActiveRecord::Migration[7.0]
|
||||
DROPPED_COLUMNS ||= {
|
||||
groups: %i{flair_url}
|
||||
}
|
||||
DROPPED_COLUMNS ||= { groups: %i[flair_url] }
|
||||
|
||||
def up
|
||||
DROPPED_COLUMNS.each do |table, columns|
|
||||
Migration::ColumnDropper.execute_drop(table, columns)
|
||||
end
|
||||
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }
|
||||
end
|
||||
|
||||
def down
|
||||
|
||||
@@ -3,7 +3,12 @@
|
||||
class SecurityLogOutInviteRedemptionInvitedUsers < ActiveRecord::Migration[7.0]
|
||||
def up
|
||||
# 20220606061813 was added shortly before the vulnerability was introduced
|
||||
vulnerable_since = DB.query_single("SELECT created_at FROM schema_migration_details WHERE version='20220606061813'")[0]
|
||||
vulnerable_since =
|
||||
DB.query_single(
|
||||
"SELECT created_at FROM schema_migration_details WHERE version='20220606061813'",
|
||||
)[
|
||||
0
|
||||
]
|
||||
|
||||
DB.exec(<<~SQL, vulnerable_since: vulnerable_since)
|
||||
DELETE FROM user_auth_tokens
|
||||
|
||||
@@ -1,19 +1,12 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'migration/column_dropper'
|
||||
require "migration/column_dropper"
|
||||
|
||||
class DropOldBookmarkColumnsV2 < ActiveRecord::Migration[7.0]
|
||||
DROPPED_COLUMNS ||= {
|
||||
bookmarks: %i{
|
||||
post_id
|
||||
for_topic
|
||||
}
|
||||
}
|
||||
DROPPED_COLUMNS ||= { bookmarks: %i[post_id for_topic] }
|
||||
|
||||
def up
|
||||
DROPPED_COLUMNS.each do |table, columns|
|
||||
Migration::ColumnDropper.execute_drop(table, columns)
|
||||
end
|
||||
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }
|
||||
end
|
||||
|
||||
def down
|
||||
|
||||
Reference in New Issue
Block a user