Skip to content

A platform for community discussion. Free, open, simple.

DEV: Apply syntax_tree formatting to `db/*`

David Taylorb0fda61a8e75
diff --git a/.streerc b/.streerc
index 016c131272c..b43ee5bb6ee 100644
--- a/.streerc
+++ b/.streerc
@@ -1,5 +1,4 @@
--print-width=100
--plugins=plugin/trailing_comma,disable_ternary
--ignore-files=app/*
---ignore-files=db/*
--ignore-files=lib/*
diff --git a/db/api_test_seeds.rb b/db/api_test_seeds.rb
index 17c3256e976..d8d4aa074a2 100644
--- a/db/api_test_seeds.rb
+++ b/db/api_test_seeds.rb
@@ -1,5 +1,14 @@
# frozen_string_literal: true
-user = User.where(username: "test_user").first_or_create(name: "Test User", email: "[email protected]", password: SecureRandom.hex, username: "test_user", approved: true, active: true, admin: true)
+user =
+ User.where(username: "test_user").first_or_create(
+ name: "Test User",
+ email: "[email protected]",
+ password: SecureRandom.hex,
+ username: "test_user",
+ approved: true,
+ active: true,
+ admin: true,
+ )
UserAuthToken.generate!(user_id: user.id)
-ApiKey.create(key: 'test_d7fd0429940', user_id: user.id, created_by_id: user.id)
+ApiKey.create(key: "test_d7fd0429940", user_id: user.id, created_by_id: user.id)
diff --git a/db/fixtures/001_refresh.rb b/db/fixtures/001_refresh.rb
index 3e0d603b93c..b7e737c632f 100644
--- a/db/fixtures/001_refresh.rb
+++ b/db/fixtures/001_refresh.rb
@@ -12,7 +12,11 @@ class SeedData::Refresher
# Not that reset_column_information is not thread safe so we have to be careful
# not to run it concurrently within the same process.
ActiveRecord::Base.connection.tables.each do |table|
- table.classify.constantize.reset_column_information rescue nil
+ begin
+ table.classify.constantize.reset_column_information
+ rescue StandardError
+ nil
+ end
end
@refreshed = true
diff --git a/db/fixtures/002_groups.rb b/db/fixtures/002_groups.rb
index d9cc999bebe..b7c04101c72 100644
--- a/db/fixtures/002_groups.rb
+++ b/db/fixtures/002_groups.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
Group.ensure_automatic_groups!
-if g = Group.find_by(name: 'trust_level_5', id: 15)
+if g = Group.find_by(name: "trust_level_5", id: 15)
g.destroy!
end
-Group.where(name: 'everyone').update_all(visibility_level: Group.visibility_levels[:staff])
+Group.where(name: "everyone").update_all(visibility_level: Group.visibility_levels[:staff])
diff --git a/db/fixtures/003_post_action_types.rb b/db/fixtures/003_post_action_types.rb
index c6a49495738..10870f90dc5 100644
--- a/db/fixtures/003_post_action_types.rb
+++ b/db/fixtures/003_post_action_types.rb
@@ -2,16 +2,16 @@
PostActionType.seed do |s|
s.id = PostActionType.types[:like]
- s.name_key = 'like'
+ s.name_key = "like"
s.is_flag = false
- s.icon = 'heart'
+ s.icon = "heart"
s.position = 2
end
if PostActionType.types[:off_topic]
PostActionType.seed do |s|
s.id = PostActionType.types[:off_topic]
- s.name_key = 'off_topic'
+ s.name_key = "off_topic"
s.is_flag = true
s.position = 3
end
@@ -20,7 +20,7 @@ end
if PostActionType.types[:inappropriate]
PostActionType.seed do |s|
s.id = PostActionType.types[:inappropriate]
- s.name_key = 'inappropriate'
+ s.name_key = "inappropriate"
s.is_flag = true
s.position = 4
end
@@ -29,7 +29,7 @@ end
if PostActionType.types[:spam]
PostActionType.seed do |s|
s.id = PostActionType.types[:spam]
- s.name_key = 'spam'
+ s.name_key = "spam"
s.is_flag = true
s.position = 6
end
@@ -38,7 +38,7 @@ end
if PostActionType.types[:notify_user]
PostActionType.seed do |s|
s.id = PostActionType.types[:notify_user]
- s.name_key = 'notify_user'
+ s.name_key = "notify_user"
s.is_flag = true
s.position = 7
end
@@ -47,7 +47,7 @@ end
if PostActionType.types[:notify_moderators]
PostActionType.seed do |s|
s.id = PostActionType.types[:notify_moderators]
- s.name_key = 'notify_moderators'
+ s.name_key = "notify_moderators"
s.is_flag = true
s.position = 8
end
diff --git a/db/fixtures/006_badges.rb b/db/fixtures/006_badges.rb
index c0b3b76dfcc..1642abe64a4 100644
--- a/db/fixtures/006_badges.rb
+++ b/db/fixtures/006_badges.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'badge_queries'
+require "badge_queries"
BadgeGrouping.seed do |g|
g.id = BadgeGrouping::GettingStarted
@@ -45,9 +45,9 @@ SQL
[
[Badge::BasicUser, "Basic User", BadgeType::Bronze],
- [Badge::Member, "Member", BadgeType::Bronze],
- [Badge::Regular, "Regular", BadgeType::Silver],
- [Badge::Leader, "Leader", BadgeType::Gold],
+ [Badge::Member, "Member", BadgeType::Bronze],
+ [Badge::Regular, "Regular", BadgeType::Silver],
+ [Badge::Leader, "Leader", BadgeType::Gold],
].each do |id, name, type|
Badge.seed do |b|
b.id = id
@@ -179,9 +179,9 @@ Badge.seed do |b|
end
[
- [Badge::NiceShare, "Nice Share", BadgeType::Bronze, 25],
- [Badge::GoodShare, "Good Share", BadgeType::Silver, 300],
- [Badge::GreatShare, "Great Share", BadgeType::Gold, 1000],
+ [Badge::NiceShare, "Nice Share", BadgeType::Bronze, 25],
+ [Badge::GoodShare, "Good Share", BadgeType::Silver, 300],
+ [Badge::GreatShare, "Great Share", BadgeType::Gold, 1000],
].each do |id, name, level, count|
Badge.seed do |b|
b.id = id
@@ -246,12 +246,12 @@ Badge.seed do |b|
end
[
- [Badge::NicePost, "Nice Post", BadgeType::Bronze, false],
- [Badge::GoodPost, "Good Post", BadgeType::Silver, false],
- [Badge::GreatPost, "Great Post", BadgeType::Gold, false],
- [Badge::NiceTopic, "Nice Topic", BadgeType::Bronze, true],
- [Badge::GoodTopic, "Good Topic", BadgeType::Silver, true],
- [Badge::GreatTopic, "Great Topic", BadgeType::Gold, true],
+ [Badge::NicePost, "Nice Post", BadgeType::Bronze, false],
+ [Badge::GoodPost, "Good Post", BadgeType::Silver, false],
+ [Badge::GreatPost, "Great Post", BadgeType::Gold, false],
+ [Badge::NiceTopic, "Nice Topic", BadgeType::Bronze, true],
+ [Badge::GoodTopic, "Good Topic", BadgeType::Silver, true],
+ [Badge::GreatTopic, "Great Topic", BadgeType::Gold, true],
].each do |id, name, type, topic|
Badge.seed do |b|
b.id = id
@@ -281,9 +281,9 @@ Badge.seed do |b|
end
[
- [Badge::PopularLink, "Popular Link", BadgeType::Bronze, 50],
- [Badge::HotLink, "Hot Link", BadgeType::Silver, 300],
- [Badge::FamousLink, "Famous Link", BadgeType::Gold, 1000],
+ [Badge::PopularLink, "Popular Link", BadgeType::Bronze, 50],
+ [Badge::HotLink, "Hot Link", BadgeType::Silver, 300],
+ [Badge::FamousLink, "Famous Link", BadgeType::Gold, 1000],
].each do |id, name, level, count|
Badge.seed do |b|
b.id = id
@@ -302,8 +302,8 @@ end
[
[Badge::Appreciated, "Appreciated", BadgeType::Bronze, 1, 20],
- [Badge::Respected, "Respected", BadgeType::Silver, 2, 100],
- [Badge::Admired, "Admired", BadgeType::Gold, 5, 300],
+ [Badge::Respected, "Respected", BadgeType::Silver, 2, 100],
+ [Badge::Admired, "Admired", BadgeType::Gold, 5, 300],
].each do |id, name, level, like_count, post_count|
Badge.seed do |b|
b.id = id
@@ -319,9 +319,9 @@ end
end
[
- [Badge::ThankYou, "Thank You", BadgeType::Bronze, 20, 10],
- [Badge::GivesBack, "Gives Back", BadgeType::Silver, 100, 100],
- [Badge::Empathetic, "Empathetic", BadgeType::Gold, 500, 1000]
+ [Badge::ThankYou, "Thank You", BadgeType::Bronze, 20, 10],
+ [Badge::GivesBack, "Gives Back", BadgeType::Silver, 100, 100],
+ [Badge::Empathetic, "Empathetic", BadgeType::Gold, 500, 1000],
].each do |id, name, level, count, ratio|
Badge.seed do |b|
b.id = id
@@ -337,9 +337,9 @@ end
end
[
- [Badge::OutOfLove, "Out of Love", BadgeType::Bronze, 1],
- [Badge::HigherLove, "Higher Love", BadgeType::Silver, 5],
- [Badge::CrazyInLove, "Crazy in Love", BadgeType::Gold, 20],
+ [Badge::OutOfLove, "Out of Love", BadgeType::Bronze, 1],
+ [Badge::HigherLove, "Higher Love", BadgeType::Silver, 5],
+ [Badge::CrazyInLove, "Crazy in Love", BadgeType::Gold, 20],
].each do |id, name, level, count|
Badge.seed do |b|
b.id = id
@@ -422,7 +422,7 @@ end
[
[Badge::Enthusiast, "Enthusiast", BadgeType::Bronze, 10],
[Badge::Aficionado, "Aficionado", BadgeType::Silver, 100],
- [Badge::Devotee, "Devotee", BadgeType::Gold, 365],
+ [Badge::Devotee, "Devotee", BadgeType::Gold, 365],
].each do |id, name, level, days|
Badge.seed do |b|
b.id = id
@@ -437,9 +437,11 @@ end
end
end
-Badge.where("NOT system AND id < 100").each do |badge|
- new_id = [Badge.maximum(:id) + 1, 100].max
- old_id = badge.id
- badge.update_columns(id: new_id)
- UserBadge.where(badge_id: old_id).update_all(badge_id: new_id)
-end
+Badge
+ .where("NOT system AND id < 100")
+ .each do |badge|
+ new_id = [Badge.maximum(:id) + 1, 100].max
+ old_id = badge.id
+ badge.update_columns(id: new_id)
+ UserBadge.where(badge_id: old_id).update_all(badge_id: new_id)
+ end
diff --git a/db/fixtures/009_users.rb b/db/fixtures/009_users.rb
index b0484fd4444..d362926bb45 100644
--- a/db/fixtures/009_users.rb
+++ b/db/fixtures/009_users.rb
@@ -30,7 +30,7 @@ end
UserOption.where(user_id: -1).update_all(
email_messages_level: UserOption.email_level_types[:never],
- email_level: UserOption.email_level_types[:never]
+ email_level: UserOption.email_level_types[:never],
)
Group.user_trust_level_change!(-1, TrustLevel[4])
@@ -44,22 +44,25 @@ if ENV["SMOKE"] == "1"
ue.user_id = 0
end
- smoke_user = User.seed do |u|
- u.id = 0
- u.name = "smoke_user"
- u.username = "smoke_user"
- u.username_lower = "smoke_user"
- u.password = "P4ssw0rd"
- u.active = true
- u.approved = true
- u.approved_at = Time.now
- u.trust_level = TrustLevel[3]
- end.first
+ smoke_user =
+ User
+ .seed do |u|
+ u.id = 0
+ u.name = "smoke_user"
+ u.username = "smoke_user"
+ u.username_lower = "smoke_user"
+ u.password = "P4ssw0rd"
+ u.active = true
+ u.approved = true
+ u.approved_at = Time.now
+ u.trust_level = TrustLevel[3]
+ end
+ .first
UserOption.where(user_id: smoke_user.id).update_all(
email_digests: false,
email_messages_level: UserOption.email_level_types[:never],
- email_level: UserOption.email_level_types[:never]
+ email_level: UserOption.email_level_types[:never],
)
EmailToken.where(user_id: smoke_user.id).update_all(confirmed: true)
diff --git a/db/fixtures/500_categories.rb b/db/fixtures/500_categories.rb
index 060969b72e6..a743b2d0ad1 100644
--- a/db/fixtures/500_categories.rb
+++ b/db/fixtures/500_categories.rb
@@ -1,7 +1,5 @@
# frozen_string_literal: true
-require 'seed_data/categories'
+require "seed_data/categories"
-if !Rails.env.test?
- SeedData::Categories.with_default_locale.create
-end
+SeedData::Categories.with_default_locale.create if !Rails.env.test?
diff --git a/db/fixtures/600_themes.rb b/db/fixtures/600_themes.rb
index 483214303f9..ce01f8eb1ce 100644
--- a/db/fixtures/600_themes.rb
+++ b/db/fixtures/600_themes.rb
@@ -10,23 +10,28 @@ if !Theme.exists?
{ name: I18n.t("color_schemes.wcag_dark"), base_scheme_id: "WCAG Dark" },
{ name: I18n.t("color_schemes.dracula"), base_scheme_id: "Dracula" },
{ name: I18n.t("color_schemes.solarized_light"), base_scheme_id: "Solarized Light" },
- { name: I18n.t("color_schemes.solarized_dark"), base_scheme_id: "Solarized Dark" }
+ { name: I18n.t("color_schemes.solarized_dark"), base_scheme_id: "Solarized Dark" },
]
color_schemes.each do |cs|
scheme = ColorScheme.find_by(base_scheme_id: cs[:base_scheme_id])
- scheme ||= ColorScheme.create_from_base(name: cs[:name], via_wizard: true, base_scheme_id: cs[:base_scheme_id], user_selectable: true)
+ scheme ||=
+ ColorScheme.create_from_base(
+ name: cs[:name],
+ via_wizard: true,
+ base_scheme_id: cs[:base_scheme_id],
+ user_selectable: true,
+ )
end
- name = I18n.t('color_schemes.default_theme_name')
+ name = I18n.t("color_schemes.default_theme_name")
default_theme = Theme.create!(name: name, user_id: -1)
default_theme.set_default!
- if SiteSetting.default_dark_mode_color_scheme_id == SiteSetting.defaults[:default_dark_mode_color_scheme_id]
+ if SiteSetting.default_dark_mode_color_scheme_id ==
+ SiteSetting.defaults[:default_dark_mode_color_scheme_id]
dark_scheme_id = ColorScheme.where(base_scheme_id: "Dark").pluck_first(:id)
- if dark_scheme_id.present?
- SiteSetting.default_dark_mode_color_scheme_id = dark_scheme_id
- end
+ SiteSetting.default_dark_mode_color_scheme_id = dark_scheme_id if dark_scheme_id.present?
end
end
diff --git a/db/fixtures/990_topics.rb b/db/fixtures/990_topics.rb
index fd29715bee3..6c036ac2739 100644
--- a/db/fixtures/990_topics.rb
+++ b/db/fixtures/990_topics.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
if !Rails.env.test?
- require 'seed_data/topics'
+ require "seed_data/topics"
topics_exist = Topic.where(<<~SQL).exists?
id NOT IN (
diff --git a/db/migrate/20000225050318_add_schema_migration_details.rb b/db/migrate/20000225050318_add_schema_migration_details.rb
index 55e6abf22b4..5a857485db0 100644
--- a/db/migrate/20000225050318_add_schema_migration_details.rb
+++ b/db/migrate/20000225050318_add_schema_migration_details.rb
@@ -19,11 +19,13 @@ class AddSchemaMigrationDetails < ActiveRecord::Migration[4.2]
add_index :schema_migration_details, [:version]
- execute("INSERT INTO schema_migration_details(version, created_at)
+ execute(
+ "INSERT INTO schema_migration_details(version, created_at)
SELECT version, current_timestamp
FROM schema_migrations
ORDER BY version
- ")
+ ",
+ )
end
def down
diff --git a/db/migrate/20120311164326_create_posts.rb b/db/migrate/20120311164326_create_posts.rb
index 3dd129cd94a..4aadc9913f7 100644
--- a/db/migrate/20120311164326_create_posts.rb
+++ b/db/migrate/20120311164326_create_posts.rb
@@ -11,6 +11,6 @@ class CreatePosts < ActiveRecord::Migration[4.2]
t.timestamps null: false
end
- add_index :posts, [:forum_thread_id, :created_at]
+ add_index :posts, %i[forum_thread_id created_at]
end
end
diff --git a/db/migrate/20120311210245_create_sites.rb b/db/migrate/20120311210245_create_sites.rb
index 4246a6ee7e8..6778ee32fdc 100644
--- a/db/migrate/20120311210245_create_sites.rb
+++ b/db/migrate/20120311210245_create_sites.rb
@@ -2,7 +2,7 @@
class CreateSites < ActiveRecord::Migration[4.2]
def change
- create_table :sites do |t|
+ create_table :sites do |t|
t.string :title, limit: 100, null: false
t.timestamps null: false
end
diff --git a/db/migrate/20120423142820_fix_post_indices.rb b/db/migrate/20120423142820_fix_post_indices.rb
index 2d1042663c9..19e7d691224 100644
--- a/db/migrate/20120423142820_fix_post_indices.rb
+++ b/db/migrate/20120423142820_fix_post_indices.rb
@@ -2,12 +2,12 @@
class FixPostIndices < ActiveRecord::Migration[4.2]
def up
- remove_index :posts, [:forum_thread_id, :created_at]
- add_index :posts, [:forum_thread_id, :post_number]
+ remove_index :posts, %i[forum_thread_id created_at]
+ add_index :posts, %i[forum_thread_id post_number]
end
def down
- remove_index :posts, [:forum_thread_id, :post_number]
- add_index :posts, [:forum_thread_id, :created_at]
+ remove_index :posts, %i[forum_thread_id post_number]
+ add_index :posts, %i[forum_thread_id created_at]
end
end
diff --git a/db/migrate/20120425145456_add_display_username_to_users.rb b/db/migrate/20120425145456_add_display_username_to_users.rb
index e88c4ee0ca5..1eefd12487b 100644
--- a/db/migrate/20120425145456_add_display_username_to_users.rb
+++ b/db/migrate/20120425145456_add_display_username_to_users.rb
@@ -13,5 +13,4 @@ class AddDisplayUsernameToUsers < ActiveRecord::Migration[4.2]
execute "UPDATE users SET username = display_username"
remove_column :users, :display_username
end
-
end
diff --git a/db/migrate/20120427154330_create_vestal_versions.rb b/db/migrate/20120427154330_create_vestal_versions.rb
index 364592430f6..ae88fd24116 100644
--- a/db/migrate/20120427154330_create_vestal_versions.rb
+++ b/db/migrate/20120427154330_create_vestal_versions.rb
@@ -5,18 +5,18 @@ class CreateVestalVersions < ActiveRecord::Migration[4.2]
create_table :versions do |t|
t.belongs_to :versioned, polymorphic: true
t.belongs_to :user, polymorphic: true
- t.string :user_name
- t.text :modifications
+ t.string :user_name
+ t.text :modifications
t.integer :number
t.integer :reverted_from
- t.string :tag
+ t.string :tag
t.timestamps null: false
end
change_table :versions do |t|
- t.index [:versioned_id, :versioned_type]
- t.index [:user_id, :user_type]
+ t.index %i[versioned_id versioned_type]
+ t.index %i[user_id user_type]
t.index :user_name
t.index :number
t.index :tag
diff --git a/db/migrate/20120502183240_add_created_by_to_forum_threads.rb b/db/migrate/20120502183240_add_created_by_to_forum_threads.rb
index 62f76731b38..90c3e678833 100644
--- a/db/migrate/20120502183240_add_created_by_to_forum_threads.rb
+++ b/db/migrate/20120502183240_add_created_by_to_forum_threads.rb
@@ -13,5 +13,4 @@ class AddCreatedByToForumThreads < ActiveRecord::Migration[4.2]
def down
remove_column :forum_threads, :user_id
end
-
end
diff --git a/db/migrate/20120502192121_add_last_post_user_id_to_forum_threads.rb b/db/migrate/20120502192121_add_last_post_user_id_to_forum_threads.rb
index 174e4f99d9a..9d1701d9b89 100644
--- a/db/migrate/20120502192121_add_last_post_user_id_to_forum_threads.rb
+++ b/db/migrate/20120502192121_add_last_post_user_id_to_forum_threads.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
class AddLastPostUserIdToForumThreads < ActiveRecord::Migration[4.2]
-
def up
add_column :forum_threads, :last_post_user_id, :integer
@@ -14,5 +13,4 @@ class AddLastPostUserIdToForumThreads < ActiveRecord::Migration[4.2]
def down
remove_column :forum_threads, :last_post_user_id
end
-
end
diff --git a/db/migrate/20120507144132_create_expressions.rb b/db/migrate/20120507144132_create_expressions.rb
index 8c2aba4cc97..5f7fdbb5c61 100644
--- a/db/migrate/20120507144132_create_expressions.rb
+++ b/db/migrate/20120507144132_create_expressions.rb
@@ -10,6 +10,9 @@ class CreateExpressions < ActiveRecord::Migration[4.2]
t.timestamps null: false
end
- add_index :expressions, [:parent_id, :parent_type, :expression_type_id, :user_id], unique: true, name: "expressions_pk"
+ add_index :expressions,
+ %i[parent_id parent_type expression_type_id user_id],
+ unique: true,
+ name: "expressions_pk"
end
end
diff --git a/db/migrate/20120507144222_create_expression_types.rb b/db/migrate/20120507144222_create_expression_types.rb
index 70630349fbb..3e83a0551dc 100644
--- a/db/migrate/20120507144222_create_expression_types.rb
+++ b/db/migrate/20120507144222_create_expression_types.rb
@@ -9,6 +9,6 @@ class CreateExpressionTypes < ActiveRecord::Migration[4.2]
t.timestamps null: false
end
- add_index :expression_types, [:site_id, :name], unique: true
+ add_index :expression_types, %i[site_id name], unique: true
end
end
diff --git a/db/migrate/20120514144549_add_reply_count_to_posts.rb b/db/migrate/20120514144549_add_reply_count_to_posts.rb
index 8209c8281f6..d0264b4270d 100644
--- a/db/migrate/20120514144549_add_reply_count_to_posts.rb
+++ b/db/migrate/20120514144549_add_reply_count_to_posts.rb
@@ -11,5 +11,4 @@ class AddReplyCountToPosts < ActiveRecord::Migration[4.2]
def down
remove_column :posts, :reply_count
end
-
end
diff --git a/db/migrate/20120518200115_create_read_posts.rb b/db/migrate/20120518200115_create_read_posts.rb
index c17305159ae..377220f1feb 100644
--- a/db/migrate/20120518200115_create_read_posts.rb
+++ b/db/migrate/20120518200115_create_read_posts.rb
@@ -9,11 +9,10 @@ class CreateReadPosts < ActiveRecord::Migration[4.2]
t.column :seen, :integer, null: false
end
- add_index :read_posts, [:forum_thread_id, :user_id, :page], unique: true
+ add_index :read_posts, %i[forum_thread_id user_id page], unique: true
end
def down
drop_table :read_posts
end
-
end
diff --git a/db/migrate/20120519182212_create_last_read_posts.rb b/db/migrate/20120519182212_create_last_read_posts.rb
index 3b9e47b84f5..23f07207014 100644
--- a/db/migrate/20120519182212_create_last_read_posts.rb
+++ b/db/migrate/20120519182212_create_last_read_posts.rb
@@ -9,6 +9,6 @@ class CreateLastReadPosts < ActiveRecord::Migration[4.2]
t.timestamps null: false
end
- add_index :last_read_posts, [:user_id, :forum_thread_id], unique: true
+ add_index :last_read_posts, %i[user_id forum_thread_id], unique: true
end
end
diff --git a/db/migrate/20120523180723_create_views.rb b/db/migrate/20120523180723_create_views.rb
index 78da1994781..a1ff9258a59 100644
--- a/db/migrate/20120523180723_create_views.rb
+++ b/db/migrate/20120523180723_create_views.rb
@@ -3,14 +3,14 @@
class CreateViews < ActiveRecord::Migration[4.2]
def change
create_table :views, id: false do |t|
- t.integer :parent_id, null: false
- t.string :parent_type, limit: 50, null: false
- t.integer :ip, limit: 8, null: false
+ t.integer :parent_id, null: false
+ t.string :parent_type, limit: 50, null: false
+ t.integer :ip, limit: 8, null: false
t.datetime :viewed_at, null: false
- t.integer :user_id, null: true
+ t.integer :user_id, null: true
end
- add_index :views, [:parent_id, :parent_type]
- add_index :views, [:parent_id, :parent_type, :ip, :viewed_at], unique: true, name: "unique_views"
+ add_index :views, %i[parent_id parent_type]
+ add_index :views, %i[parent_id parent_type ip viewed_at], unique: true, name: "unique_views"
end
end
diff --git a/db/migrate/20120525194845_add_avg_time_to_forum_threads.rb b/db/migrate/20120525194845_add_avg_time_to_forum_threads.rb
index 0d4533e910a..95e2e4780ae 100644
--- a/db/migrate/20120525194845_add_avg_time_to_forum_threads.rb
+++ b/db/migrate/20120525194845_add_avg_time_to_forum_threads.rb
@@ -10,5 +10,4 @@ class AddAvgTimeToForumThreads < ActiveRecord::Migration[4.2]
def down
remove_column :forum_threads, :avg_time
end
-
end
diff --git a/db/migrate/20120529175956_create_uploads.rb b/db/migrate/20120529175956_create_uploads.rb
index 02d7cc39b95..a3756d5d96a 100644
--- a/db/migrate/20120529175956_create_uploads.rb
+++ b/db/migrate/20120529175956_create_uploads.rb
@@ -5,16 +5,15 @@ class CreateUploads < ActiveRecord::Migration[4.2]
create_table :uploads do |t|
t.integer :user_id, null: false
t.integer :forum_thread_id, null: false
- t.string :original_filename, null: false
+ t.string :original_filename, null: false
t.integer :filesize, null: false
t.integer :width, null: true
t.integer :height, null: true
- t.string :url, null: false
+ t.string :url, null: false
t.timestamps null: false
end
add_index :uploads, :forum_thread_id
add_index :uploads, :user_id
end
-
end
diff --git a/db/migrate/20120529202707_create_stars.rb b/db/migrate/20120529202707_create_stars.rb
index 99655810df8..5c8df40d494 100644
--- a/db/migrate/20120529202707_create_stars.rb
+++ b/db/migrate/20120529202707_create_stars.rb
@@ -3,12 +3,12 @@
class CreateStars < ActiveRecord::Migration[4.2]
def change
create_table :stars, id: false do |t|
- t.integer :parent_id, null: false
- t.string :parent_type, limit: 50, null: false
- t.integer :user_id, null: true
+ t.integer :parent_id, null: false
+ t.string :parent_type, limit: 50, null: false
+ t.integer :user_id, null: true
t.timestamps null: false
end
- add_index :stars, [:parent_id, :parent_type, :user_id]
+ add_index :stars, %i[parent_id parent_type user_id]
end
end
diff --git a/db/migrate/20120530150726_create_forum_thread_user.rb b/db/migrate/20120530150726_create_forum_thread_user.rb
index 25974993874..7196aac944c 100644
--- a/db/migrate/20120530150726_create_forum_thread_user.rb
+++ b/db/migrate/20120530150726_create_forum_thread_user.rb
@@ -3,17 +3,17 @@
class CreateForumThreadUser < ActiveRecord::Migration[4.2]
def up
create_table :forum_thread_users, id: false do |t|
- t.integer :user_id, null: false
- t.integer :forum_thread_id, null: false
- t.boolean :starred, null: false, default: false
- t.boolean :posted, null: false, default: false
- t.integer :last_read_post_number, null: false, default: 1
+ t.integer :user_id, null: false
+ t.integer :forum_thread_id, null: false
+ t.boolean :starred, null: false, default: false
+ t.boolean :posted, null: false, default: false
+ t.integer :last_read_post_number, null: false, default: 1
t.timestamps null: false
end
execute "DELETE FROM read_posts"
- add_index :forum_thread_users, [:forum_thread_id, :user_id], unique: true
+ add_index :forum_thread_users, %i[forum_thread_id user_id], unique: true
drop_table :stars
drop_table :last_read_posts
@@ -23,13 +23,13 @@ class CreateForumThreadUser < ActiveRecord::Migration[4.2]
drop_table :forum_thread_users
create_table :stars, id: false do |t|
- t.integer :parent_id, null: false
- t.string :parent_type, limit: 50, null: false
- t.integer :user_id, null: true
+ t.integer :parent_id, null: false
+ t.string :parent_type, limit: 50, null: false
+ t.integer :user_id, null: true
t.timestamps null: false
end
- add_index :stars, [:parent_id, :parent_type, :user_id]
+ add_index :stars, %i[parent_id parent_type user_id]
create_table :last_read_posts do |t|
t.integer :user_id, null: false
@@ -38,6 +38,6 @@ class CreateForumThreadUser < ActiveRecord::Migration[4.2]
t.timestamps null: false
end
- add_index :last_read_posts, [:user_id, :forum_thread_id], unique: true
+ add_index :last_read_posts, %i[user_id forum_thread_id], unique: true
end
end
diff --git a/db/migrate/20120530212912_create_forum_thread_links.rb b/db/migrate/20120530212912_create_forum_thread_links.rb
index de8b5e99622..f974247bf6a 100644
--- a/db/migrate/20120530212912_create_forum_thread_links.rb
+++ b/db/migrate/20120530212912_create_forum_thread_links.rb
@@ -6,8 +6,8 @@ class CreateForumThreadLinks < ActiveRecord::Migration[4.2]
t.integer :forum_thread_id, null: false
t.integer :post_id, null: false
t.integer :user_id, null: false
- t.string :url, limit: 500, null: false
- t.string :domain, limit: 100, null: false
+ t.string :url, limit: 500, null: false
+ t.string :domain, limit: 100, null: false
t.boolean :internal, null: false, default: false
t.integer :link_forum_thread_id, null: true
t.timestamps null: false
diff --git a/db/migrate/20120615180517_create_bookmarks.rb b/db/migrate/20120615180517_create_bookmarks.rb
index 49433756eb7..fa1ffca61c6 100644
--- a/db/migrate/20120615180517_create_bookmarks.rb
+++ b/db/migrate/20120615180517_create_bookmarks.rb
@@ -8,6 +8,6 @@ class CreateBookmarks < ActiveRecord::Migration[4.2]
t.timestamps null: false
end
- add_index :bookmarks, [:user_id, :post_id], unique: true
+ add_index :bookmarks, %i[user_id post_id], unique: true
end
end
diff --git a/db/migrate/20120618212349_create_post_timings.rb b/db/migrate/20120618212349_create_post_timings.rb
index b8ea4a28589..c4297820ea8 100644
--- a/db/migrate/20120618212349_create_post_timings.rb
+++ b/db/migrate/20120618212349_create_post_timings.rb
@@ -9,7 +9,7 @@ class CreatePostTimings < ActiveRecord::Migration[4.2]
t.integer :msecs, null: false
end
- add_index :post_timings, [:thread_id, :post_number]
- add_index :post_timings, [:thread_id, :post_number, :user_id], unique: true
+ add_index :post_timings, %i[thread_id post_number]
+ add_index :post_timings, %i[thread_id post_number user_id], unique: true
end
end
diff --git a/db/migrate/20120618214856_create_message_bus.rb b/db/migrate/20120618214856_create_message_bus.rb
index 929fb0fea57..a71c312eb49 100644
--- a/db/migrate/20120618214856_create_message_bus.rb
+++ b/db/migrate/20120618214856_create_message_bus.rb
@@ -11,5 +11,4 @@ class CreateMessageBus < ActiveRecord::Migration[4.2]
add_index :message_bus, [:created_at]
end
-
end
diff --git a/db/migrate/20120619150807_fix_post_timings.rb b/db/migrate/20120619150807_fix_post_timings.rb
index c2ff90805a5..49bd065b3bd 100644
--- a/db/migrate/20120619150807_fix_post_timings.rb
+++ b/db/migrate/20120619150807_fix_post_timings.rb
@@ -2,12 +2,14 @@
class FixPostTimings < ActiveRecord::Migration[4.2]
def up
- remove_index :post_timings, [:thread_id, :post_number]
- remove_index :post_timings, [:thread_id, :post_number, :user_id]
+ remove_index :post_timings, %i[thread_id post_number]
+ remove_index :post_timings, %i[thread_id post_number user_id]
rename_column :post_timings, :thread_id, :forum_thread_id
- add_index :post_timings, [:forum_thread_id, :post_number], name: 'post_timings_summary'
- add_index :post_timings, [:forum_thread_id, :post_number, :user_id], unique: true, name: 'post_timings_unique'
-
+ add_index :post_timings, %i[forum_thread_id post_number], name: "post_timings_summary"
+ add_index :post_timings,
+ %i[forum_thread_id post_number user_id],
+ unique: true,
+ name: "post_timings_unique"
end
def down
diff --git a/db/migrate/20120619172714_add_post_number_to_bookmarks.rb b/db/migrate/20120619172714_add_post_number_to_bookmarks.rb
index 6976191f42a..d411d601f25 100644
--- a/db/migrate/20120619172714_add_post_number_to_bookmarks.rb
+++ b/db/migrate/20120619172714_add_post_number_to_bookmarks.rb
@@ -11,6 +11,6 @@ class AddPostNumberToBookmarks < ActiveRecord::Migration[4.2]
t.timestamps null: false
end
- add_index :bookmarks, [:user_id, :forum_thread_id, :post_number], unique: true
+ add_index :bookmarks, %i[user_id forum_thread_id post_number], unique: true
end
end
diff --git a/db/migrate/20120622200242_create_notifications.rb b/db/migrate/20120622200242_create_notifications.rb
index b6f8a320b77..d43b29dfb21 100644
--- a/db/migrate/20120622200242_create_notifications.rb
+++ b/db/migrate/20120622200242_create_notifications.rb
@@ -10,6 +10,6 @@ class CreateNotifications < ActiveRecord::Migration[4.2]
t.timestamps null: false
end
- add_index :notifications, [:user_id, :created_at]
+ add_index :notifications, %i[user_id created_at]
end
end
diff --git a/db/migrate/20120625145714_add_seen_notification_id_to_users.rb b/db/migrate/20120625145714_add_seen_notification_id_to_users.rb
index 75b975dd7c1..ffae6a811d6 100644
--- a/db/migrate/20120625145714_add_seen_notification_id_to_users.rb
+++ b/db/migrate/20120625145714_add_seen_notification_id_to_users.rb
@@ -2,7 +2,6 @@
class AddSeenNotificationIdToUsers < ActiveRecord::Migration[4.2]
def change
-
execute "TRUNCATE TABLE notifications"
add_column :users, :seen_notificaiton_id, :integer, default: 0, null: false
diff --git a/db/migrate/20120629143908_rename_expression_type_id.rb b/db/migrate/20120629143908_rename_expression_type_id.rb
index 630cc4afae1..78958d82df0 100644
--- a/db/migrate/20120629143908_rename_expression_type_id.rb
+++ b/db/migrate/20120629143908_rename_expression_type_id.rb
@@ -1,13 +1,12 @@
# frozen_string_literal: true
class RenameExpressionTypeId < ActiveRecord::Migration[4.2]
-
def up
add_column :expression_types, :expression_index, :integer
execute "UPDATE expression_types SET expression_index = id"
remove_column :expression_types, :id
- add_index :expression_types, [:site_id, :expression_index], unique: true
+ add_index :expression_types, %i[site_id expression_index], unique: true
end
def down
diff --git a/db/migrate/20120629150253_denormalize_expressions.rb b/db/migrate/20120629150253_denormalize_expressions.rb
index eb0e386ec1a..e81c38ba55d 100644
--- a/db/migrate/20120629150253_denormalize_expressions.rb
+++ b/db/migrate/20120629150253_denormalize_expressions.rb
@@ -2,7 +2,6 @@
class DenormalizeExpressions < ActiveRecord::Migration[4.2]
def change
-
# Denormalizing this makes our queries so, so, so much nicer
add_column :posts, :expression1_count, :integer, null: false, default: 0
@@ -22,5 +21,4 @@ class DenormalizeExpressions < ActiveRecord::Migration[4.2]
execute "update forum_threads set expression#{i}_count = (select sum(expression#{i}_count) from posts where forum_thread_id = forum_threads.id)"
end
end
-
end
diff --git a/db/migrate/20120629151243_make_expressions_less_generic.rb b/db/migrate/20120629151243_make_expressions_less_generic.rb
index 030d5bb2bd8..3ac9d1c4714 100644
--- a/db/migrate/20120629151243_make_expressions_less_generic.rb
+++ b/db/migrate/20120629151243_make_expressions_less_generic.rb
@@ -6,7 +6,10 @@ class MakeExpressionsLessGeneric < ActiveRecord::Migration[4.2]
rename_column :expressions, :expression_type_id, :expression_index
remove_column :expressions, :parent_type
- add_index :expressions, [:post_id, :expression_index, :user_id], unique: true, name: 'unique_by_user'
+ add_index :expressions,
+ %i[post_id expression_index user_id],
+ unique: true,
+ name: "unique_by_user"
end
def down
@@ -14,5 +17,4 @@ class MakeExpressionsLessGeneric < ActiveRecord::Migration[4.2]
rename_column :expressions, :expression_index, :expression_type_id
add_column :expressions, :parent_type, :string, null: true
end
-
end
diff --git a/db/migrate/20120629182637_create_incoming_links.rb b/db/migrate/20120629182637_create_incoming_links.rb
index 70a1ffa2e93..9b61bb774be 100644
--- a/db/migrate/20120629182637_create_incoming_links.rb
+++ b/db/migrate/20120629182637_create_incoming_links.rb
@@ -12,6 +12,6 @@ class CreateIncomingLinks < ActiveRecord::Migration[4.2]
t.timestamps null: false
end
- add_index :incoming_links, [:site_id, :forum_thread_id, :post_number], name: 'incoming_index'
+ add_index :incoming_links, %i[site_id forum_thread_id post_number], name: "incoming_index"
end
end
diff --git a/db/migrate/20120702211427_create_replies.rb b/db/migrate/20120702211427_create_replies.rb
index a252a11501e..ef792918b1d 100644
--- a/db/migrate/20120702211427_create_replies.rb
+++ b/db/migrate/20120702211427_create_replies.rb
@@ -8,7 +8,7 @@ class CreateReplies < ActiveRecord::Migration[4.2]
t.timestamps null: false
end
- add_index :post_replies, [:post_id, :reply_id], unique: true
+ add_index :post_replies, %i[post_id reply_id], unique: true
execute "INSERT INTO post_replies (post_id, reply_id, created_at, updated_at)
SELECT p2.id, p.id, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP
diff --git a/db/migrate/20120712150500_create_categories.rb b/db/migrate/20120712150500_create_categories.rb
index 3f5ef230fdb..f94bbcf50eb 100644
--- a/db/migrate/20120712150500_create_categories.rb
+++ b/db/migrate/20120712150500_create_categories.rb
@@ -4,7 +4,7 @@ class CreateCategories < ActiveRecord::Migration[4.2]
def up
create_table :categories do |t|
t.string :name, limit: 50, null: false
- t.string :color, limit: 6, null: false, default: '0088CC'
+ t.string :color, limit: 6, null: false, default: "0088CC"
t.integer :forum_thread_id, null: true
t.integer :top1_forum_thread_id, null: true
t.integer :top2_forum_thread_id, null: true
@@ -26,5 +26,4 @@ class CreateCategories < ActiveRecord::Migration[4.2]
def down
drop_table :categories
end
-
end
diff --git a/db/migrate/20120712151934_add_category_id_to_forum_threads.rb b/db/migrate/20120712151934_add_category_id_to_forum_threads.rb
index d9feac5477e..df8dca72da9 100644
--- a/db/migrate/20120712151934_add_category_id_to_forum_threads.rb
+++ b/db/migrate/20120712151934_add_category_id_to_forum_threads.rb
@@ -16,5 +16,4 @@ class AddCategoryIdToForumThreads < ActiveRecord::Migration[4.2]
remove_column :forum_threads, :category_id
add_column :forum_threads, :tag, :string, limit: 20
end
-
end
diff --git a/db/migrate/20120713201324_create_category_featured_threads.rb b/db/migrate/20120713201324_create_category_featured_threads.rb
index 30082244338..38df7f177ff 100644
--- a/db/migrate/20120713201324_create_category_featured_threads.rb
+++ b/db/migrate/20120713201324_create_category_featured_threads.rb
@@ -8,6 +8,9 @@ class CreateCategoryFeaturedThreads < ActiveRecord::Migration[4.2]
t.timestamps null: false
end
- add_index :category_featured_threads, [:category_id, :forum_thread_id], unique: true, name: 'cat_featured_threads'
+ add_index :category_featured_threads,
+ %i[category_id forum_thread_id],
+ unique: true,
+ name: "cat_featured_threads"
end
end
diff --git a/db/migrate/20120718044955_create_user_open_ids.rb b/db/migrate/20120718044955_create_user_open_ids.rb
index 19e0c0e7979..aa9133dd1bd 100644
--- a/db/migrate/20120718044955_create_user_open_ids.rb
+++ b/db/migrate/20120718044955_create_user_open_ids.rb
@@ -10,6 +10,5 @@ class CreateUserOpenIds < ActiveRecord::Migration[4.2]
end
add_index :user_open_ids, [:url]
-
end
end
diff --git a/db/migrate/20120719004636_add_email_hashed_password_name_salt_to_users.rb b/db/migrate/20120719004636_add_email_hashed_password_name_salt_to_users.rb
index 355e4c42b35..db77582327c 100644
--- a/db/migrate/20120719004636_add_email_hashed_password_name_salt_to_users.rb
+++ b/db/migrate/20120719004636_add_email_hashed_password_name_salt_to_users.rb
@@ -17,7 +17,6 @@ class AddEmailHashedPasswordNameSaltToUsers < ActiveRecord::Migration[4.2]
add_column :users, :activation_key, :string, limit: 32
add_column :user_open_ids, :active, :boolean, null: false
-
end
def down
diff --git a/db/migrate/20120720162422_add_forum_id_to_categories.rb b/db/migrate/20120720162422_add_forum_id_to_categories.rb
index 8868e767855..d9213e5d1ee 100644
--- a/db/migrate/20120720162422_add_forum_id_to_categories.rb
+++ b/db/migrate/20120720162422_add_forum_id_to_categories.rb
@@ -10,5 +10,4 @@ class AddForumIdToCategories < ActiveRecord::Migration[4.2]
def down
remove_column :categories, :forum_id
end
-
end
diff --git a/db/migrate/20120726201830_add_invisible_to_forum_thread.rb b/db/migrate/20120726201830_add_invisible_to_forum_thread.rb
index faad5921203..50d29688ea4 100644
--- a/db/migrate/20120726201830_add_invisible_to_forum_thread.rb
+++ b/db/migrate/20120726201830_add_invisible_to_forum_thread.rb
@@ -10,5 +10,4 @@ class AddInvisibleToForumThread < ActiveRecord::Migration[4.2]
remove_column :forum_threads, :invisible
change_column :categories, :excerpt, :string, limit: 250, null: true
end
-
end
diff --git a/db/migrate/20120727150428_rename_invisible.rb b/db/migrate/20120727150428_rename_invisible.rb
index 68986b1cadc..b06238881b0 100644
--- a/db/migrate/20120727150428_rename_invisible.rb
+++ b/db/migrate/20120727150428_rename_invisible.rb
@@ -2,10 +2,8 @@
class RenameInvisible < ActiveRecord::Migration[4.2]
def change
-
add_column :forum_threads, :visible, :boolean, default: true, null: false
execute "UPDATE forum_threads SET visible = CASE WHEN invisible THEN false ELSE true END"
remove_column :forum_threads, :invisible
-
end
end
diff --git a/db/migrate/20120807223020_create_actions.rb b/db/migrate/20120807223020_create_actions.rb
index 0fe02dd09aa..2a1843b7069 100644
--- a/db/migrate/20120807223020_create_actions.rb
+++ b/db/migrate/20120807223020_create_actions.rb
@@ -3,7 +3,6 @@
class CreateActions < ActiveRecord::Migration[4.2]
def change
create_table :actions do |t|
-
# I elected for multiple ids as opposed to using :as cause it makes the table
# thinner, and the joining semantics much simpler (a simple multiple left join will do)
#
@@ -20,7 +19,7 @@ class CreateActions < ActiveRecord::Migration[4.2]
t.timestamps null: false
end
- add_index :actions, [:user_id, :action_type]
+ add_index :actions, %i[user_id action_type]
add_index :actions, [:acting_user_id]
end
end
diff --git a/db/migrate/20120809020415_remove_site_id.rb b/db/migrate/20120809020415_remove_site_id.rb
index 93c242f8971..55beb920400 100644
--- a/db/migrate/20120809020415_remove_site_id.rb
+++ b/db/migrate/20120809020415_remove_site_id.rb
@@ -2,23 +2,23 @@
class RemoveSiteId < ActiveRecord::Migration[4.2]
def up
- drop_table 'sites'
- remove_index 'incoming_links', name: "incoming_index"
- add_index "incoming_links", ["forum_thread_id", "post_number"], name: "incoming_index"
- remove_column 'incoming_links', 'site_id'
- remove_index 'users', name: 'index_users_on_site_id'
- remove_column 'users', 'site_id'
+ drop_table "sites"
+ remove_index "incoming_links", name: "incoming_index"
+ add_index "incoming_links", %w[forum_thread_id post_number], name: "incoming_index"
+ remove_column "incoming_links", "site_id"
+ remove_index "users", name: "index_users_on_site_id"
+ remove_column "users", "site_id"
- remove_index 'expression_types', name: 'index_expression_types_on_site_id_and_expression_index'
- remove_index 'expression_types', name: 'index_expression_types_on_site_id_and_name'
- remove_column 'expression_types', 'site_id'
+ remove_index "expression_types", name: "index_expression_types_on_site_id_and_expression_index"
+ remove_index "expression_types", name: "index_expression_types_on_site_id_and_name"
+ remove_column "expression_types", "site_id"
add_index "expression_types", ["expression_index"], unique: true
add_index "expression_types", ["name"], unique: true
- drop_table 'forums'
+ drop_table "forums"
end
def down
- raise 'not reversable'
+ raise "not reversable"
end
end
diff --git a/db/migrate/20120809030647_remove_forum_id.rb b/db/migrate/20120809030647_remove_forum_id.rb
index e13cfade6cd..084d76c8c02 100644
--- a/db/migrate/20120809030647_remove_forum_id.rb
+++ b/db/migrate/20120809030647_remove_forum_id.rb
@@ -2,11 +2,11 @@
class RemoveForumId < ActiveRecord::Migration[4.2]
def up
- remove_column 'forum_threads', 'forum_id'
- remove_column 'categories', 'forum_id'
+ remove_column "forum_threads", "forum_id"
+ remove_column "categories", "forum_id"
end
def down
- raise 'not reversible'
+ raise "not reversible"
end
end
diff --git a/db/migrate/20120809053414_correct_indexing_on_posts.rb b/db/migrate/20120809053414_correct_indexing_on_posts.rb
index 2600244583d..d2b5e49ae67 100644
--- a/db/migrate/20120809053414_correct_indexing_on_posts.rb
+++ b/db/migrate/20120809053414_correct_indexing_on_posts.rb
@@ -13,11 +13,10 @@ from
) as c
where pp.id = c.id and pp.post_number <> c.real_number"
- remove_index "posts", ["forum_thread_id", "post_number"]
+ remove_index "posts", %w[forum_thread_id post_number]
# this needs to be unique if it is not we can not use post_number to identify a post
- add_index "posts", ["forum_thread_id", "post_number"], unique: true
-
+ add_index "posts", %w[forum_thread_id post_number], unique: true
end
def down
diff --git a/db/migrate/20120809154750_remove_index_for_now.rb b/db/migrate/20120809154750_remove_index_for_now.rb
index 44a2c1189e9..daef0e2fe26 100644
--- a/db/migrate/20120809154750_remove_index_for_now.rb
+++ b/db/migrate/20120809154750_remove_index_for_now.rb
@@ -2,12 +2,12 @@
class RemoveIndexForNow < ActiveRecord::Migration[4.2]
def up
- remove_index "posts", ["forum_thread_id", "post_number"]
- add_index "posts", ["forum_thread_id", "post_number"], unique: false
+ remove_index "posts", %w[forum_thread_id post_number]
+ add_index "posts", %w[forum_thread_id post_number], unique: false
end
def down
- remove_index "posts", ["forum_thread_id", "post_number"]
- add_index "posts", ["forum_thread_id", "post_number"], unique: true
+ remove_index "posts", %w[forum_thread_id post_number]
+ add_index "posts", %w[forum_thread_id post_number], unique: true
end
end
diff --git a/db/migrate/20120809174649_create_post_actions.rb b/db/migrate/20120809174649_create_post_actions.rb
index e437e40b543..a76ea9ede93 100644
--- a/db/migrate/20120809174649_create_post_actions.rb
+++ b/db/migrate/20120809174649_create_post_actions.rb
@@ -13,9 +13,8 @@ class CreatePostActions < ActiveRecord::Migration[4.2]
add_index :post_actions, ["post_id"]
# no support for this till rails 4
- execute 'create unique index idx_unique_actions on
- post_actions(user_id, post_action_type_id, post_id) where deleted_at is null'
-
+ execute "create unique index idx_unique_actions on
+ post_actions(user_id, post_action_type_id, post_id) where deleted_at is null"
end
def down
drop_table :post_actions
diff --git a/db/migrate/20120810064839_rename_actions_to_user_actions.rb b/db/migrate/20120810064839_rename_actions_to_user_actions.rb
index 051e2e9fef9..631fdfb8e04 100644
--- a/db/migrate/20120810064839_rename_actions_to_user_actions.rb
+++ b/db/migrate/20120810064839_rename_actions_to_user_actions.rb
@@ -2,6 +2,6 @@
class RenameActionsToUserActions < ActiveRecord::Migration[4.2]
def change
- rename_table 'actions', 'user_actions'
+ rename_table "actions", "user_actions"
end
end
diff --git a/db/migrate/20120812235417_retire_expressions.rb b/db/migrate/20120812235417_retire_expressions.rb
index a5494ccd2c2..7f0d683be15 100644
--- a/db/migrate/20120812235417_retire_expressions.rb
+++ b/db/migrate/20120812235417_retire_expressions.rb
@@ -2,7 +2,7 @@
class RetireExpressions < ActiveRecord::Migration[4.2]
def up
- execute 'insert into post_actions (post_action_type_id, user_id, post_id, created_at, updated_at)
+ execute "insert into post_actions (post_action_type_id, user_id, post_id, created_at, updated_at)
select
case
when expression_index=1 then 3
@@ -10,10 +10,10 @@ select
when expression_index=3 then 2
end
- , user_id, post_id, created_at, updated_at from expressions'
+ , user_id, post_id, created_at, updated_at from expressions"
- drop_table 'expressions'
- drop_table 'expression_types'
+ drop_table "expressions"
+ drop_table "expression_types"
end
def down
diff --git a/db/migrate/20120813004347_rename_expression_columns_in_forum_thread.rb b/db/migrate/20120813004347_rename_expression_columns_in_forum_thread.rb
index 43958a86225..f42ce2539a2 100644
--- a/db/migrate/20120813004347_rename_expression_columns_in_forum_thread.rb
+++ b/db/migrate/20120813004347_rename_expression_columns_in_forum_thread.rb
@@ -2,11 +2,10 @@
class RenameExpressionColumnsInForumThread < ActiveRecord::Migration[4.2]
def change
- rename_column 'forum_threads', 'expression1_count', 'off_topic_count'
- rename_column 'forum_threads', 'expression2_count', 'offensive_count'
- rename_column 'forum_threads', 'expression3_count', 'like_count'
- remove_column 'forum_threads', 'expression4_count'
- remove_column 'forum_threads', 'expression5_count'
-
+ rename_column "forum_threads", "expression1_count", "off_topic_count"
+ rename_column "forum_threads", "expression2_count", "offensive_count"
+ rename_column "forum_threads", "expression3_count", "like_count"
+ remove_column "forum_threads", "expression4_count"
+ remove_column "forum_threads", "expression5_count"
end
end
diff --git a/db/migrate/20120813042912_rename_expression_columns_in_posts.rb b/db/migrate/20120813042912_rename_expression_columns_in_posts.rb
index 90ac91d4159..4db02e81432 100644
--- a/db/migrate/20120813042912_rename_expression_columns_in_posts.rb
+++ b/db/migrate/20120813042912_rename_expression_columns_in_posts.rb
@@ -2,10 +2,10 @@
class RenameExpressionColumnsInPosts < ActiveRecord::Migration[4.2]
def change
- rename_column 'posts', 'expression1_count', 'off_topic_count'
- rename_column 'posts', 'expression2_count', 'offensive_count'
- rename_column 'posts', 'expression3_count', 'like_count'
- remove_column 'posts', 'expression4_count'
- remove_column 'posts', 'expression5_count'
+ rename_column "posts", "expression1_count", "off_topic_count"
+ rename_column "posts", "expression2_count", "offensive_count"
+ rename_column "posts", "expression3_count", "like_count"
+ remove_column "posts", "expression4_count"
+ remove_column "posts", "expression5_count"
end
end
diff --git a/db/migrate/20120815004411_add_unique_index_to_forum_thread_links.rb b/db/migrate/20120815004411_add_unique_index_to_forum_thread_links.rb
index ffbfd6d2787..c8b53bc59b6 100644
--- a/db/migrate/20120815004411_add_unique_index_to_forum_thread_links.rb
+++ b/db/migrate/20120815004411_add_unique_index_to_forum_thread_links.rb
@@ -2,7 +2,6 @@
class AddUniqueIndexToForumThreadLinks < ActiveRecord::Migration[4.2]
def change
-
execute "DELETE FROM forum_thread_links USING forum_thread_links ftl2
WHERE ftl2.forum_thread_id = forum_thread_links.forum_thread_id
AND ftl2.post_id = forum_thread_links.post_id
@@ -10,6 +9,9 @@ class AddUniqueIndexToForumThreadLinks < ActiveRecord::Migration[4.2]
AND ftl2.id < forum_thread_links.id"
# Add the unique index
- add_index :forum_thread_links, [:forum_thread_id, :post_id, :url], unique: true, name: 'unique_post_links'
+ add_index :forum_thread_links,
+ %i[forum_thread_id post_id url],
+ unique: true,
+ name: "unique_post_links"
end
end
diff --git a/db/migrate/20120816050526_add_unique_constraint_to_user_actions.rb b/db/migrate/20120816050526_add_unique_constraint_to_user_actions.rb
index 0b71524f63f..bee131ef9ab 100644
--- a/db/migrate/20120816050526_add_unique_constraint_to_user_actions.rb
+++ b/db/migrate/20120816050526_add_unique_constraint_to_user_actions.rb
@@ -2,6 +2,9 @@
class AddUniqueConstraintToUserActions < ActiveRecord::Migration[4.2]
def change
- add_index :user_actions, ['action_type', 'user_id', 'target_forum_thread_id', 'target_post_id', 'acting_user_id'], name: "idx_unique_rows", unique: true
+ add_index :user_actions,
+ %w[action_type user_id target_forum_thread_id target_post_id acting_user_id],
+ name: "idx_unique_rows",
+ unique: true
end
end
diff --git a/db/migrate/20120816205538_add_starred_at_to_forum_thread_user.rb b/db/migrate/20120816205538_add_starred_at_to_forum_thread_user.rb
index 8421b8b544d..f510672f1db 100644
--- a/db/migrate/20120816205538_add_starred_at_to_forum_thread_user.rb
+++ b/db/migrate/20120816205538_add_starred_at_to_forum_thread_user.rb
@@ -3,20 +3,21 @@
class AddStarredAtToForumThreadUser < ActiveRecord::Migration[4.2]
def up
add_column :forum_thread_users, :starred_at, :datetime
- DB.exec 'update forum_thread_users f set starred_at = COALESCE(created_at, ?)
+ DB.exec "update forum_thread_users f set starred_at = COALESCE(created_at, ?)
from
(
select f1.forum_thread_id, f1.user_id, t.created_at from forum_thread_users f1
left join forum_threads t on f1.forum_thread_id = t.id
) x
- where x.forum_thread_id = f.forum_thread_id and x.user_id = f.user_id', [DateTime.now]
+ where x.forum_thread_id = f.forum_thread_id and x.user_id = f.user_id",
+ [DateTime.now]
# probably makes sense to move this out to forum_thread_actions
- execute 'alter table forum_thread_users add constraint test_starred_at check(starred = false or starred_at is not null)'
+ execute "alter table forum_thread_users add constraint test_starred_at check(starred = false or starred_at is not null)"
end
def down
- execute 'alter table forum_thread_users drop constraint test_starred_at'
+ execute "alter table forum_thread_users drop constraint test_starred_at"
remove_column :forum_thread_users, :starred_at
end
end
diff --git a/db/migrate/20120824171908_create_category_featured_users.rb b/db/migrate/20120824171908_create_category_featured_users.rb
index 5a57b77214f..9d896b46d85 100644
--- a/db/migrate/20120824171908_create_category_featured_users.rb
+++ b/db/migrate/20120824171908_create_category_featured_users.rb
@@ -8,6 +8,6 @@ class CreateCategoryFeaturedUsers < ActiveRecord::Migration[4.2]
t.timestamps null: false
end
- add_index :category_featured_users, [:category_id, :user_id], unique: true
+ add_index :category_featured_users, %i[category_id user_id], unique: true
end
end
diff --git a/db/migrate/20120828204624_create_post_onebox_renders.rb b/db/migrate/20120828204624_create_post_onebox_renders.rb
index 4eadbfbd23e..6e6baa2c1a7 100644
--- a/db/migrate/20120828204624_create_post_onebox_renders.rb
+++ b/db/migrate/20120828204624_create_post_onebox_renders.rb
@@ -7,6 +7,6 @@ class CreatePostOneboxRenders < ActiveRecord::Migration[4.2]
t.references :onebox_render, null: false
t.timestamps null: false
end
- add_index :post_onebox_renders, [:post_id, :onebox_render_id], unique: true
+ add_index :post_onebox_renders, %i[post_id onebox_render_id], unique: true
end
end
diff --git a/db/migrate/20120918205931_add_sub_tag_to_forum_threads.rb b/db/migrate/20120918205931_add_sub_tag_to_forum_threads.rb
index 2b2d4e99118..74c223d0b70 100644
--- a/db/migrate/20120918205931_add_sub_tag_to_forum_threads.rb
+++ b/db/migrate/20120918205931_add_sub_tag_to_forum_threads.rb
@@ -3,6 +3,6 @@
class AddSubTagToForumThreads < ActiveRecord::Migration[4.2]
def change
add_column :forum_threads, :sub_tag, :string
- add_index :forum_threads, [:category_id, :sub_tag, :bumped_at]
+ add_index :forum_threads, %i[category_id sub_tag bumped_at]
end
end
diff --git a/db/migrate/20120919152846_add_has_best_of_to_forum_threads.rb b/db/migrate/20120919152846_add_has_best_of_to_forum_threads.rb
index c37187cef42..a8a624cc83b 100644
--- a/db/migrate/20120919152846_add_has_best_of_to_forum_threads.rb
+++ b/db/migrate/20120919152846_add_has_best_of_to_forum_threads.rb
@@ -1,10 +1,8 @@
# frozen_string_literal: true
class AddHasBestOfToForumThreads < ActiveRecord::Migration[4.2]
-
def change
add_column :forum_threads, :has_best_of, :boolean, default: false, null: false
change_column :posts, :score, :float
end
-
end
diff --git a/db/migrate/20120921055428_add_twitter_user_info.rb b/db/migrate/20120921055428_add_twitter_user_info.rb
index 8f27148c11b..b88eece0690 100644
--- a/db/migrate/20120921055428_add_twitter_user_info.rb
+++ b/db/migrate/20120921055428_add_twitter_user_info.rb
@@ -2,7 +2,7 @@
class AddTwitterUserInfo < ActiveRecord::Migration[4.2]
def change
- create_table :twitter_user_infos do |t|
+ create_table :twitter_user_infos do |t|
t.integer :user_id, null: false
t.string :screen_name, null: false
t.integer :twitter_user_id, null: false
diff --git a/db/migrate/20120921155050_create_archetypes.rb b/db/migrate/20120921155050_create_archetypes.rb
index d8f7954bed4..33626ca3588 100644
--- a/db/migrate/20120921155050_create_archetypes.rb
+++ b/db/migrate/20120921155050_create_archetypes.rb
@@ -18,5 +18,4 @@ class CreateArchetypes < ActiveRecord::Migration[4.2]
remove_column :forum_threads, :archetype_id
drop_table :archetypes
end
-
end
diff --git a/db/migrate/20121011155904_create_email_logs.rb b/db/migrate/20121011155904_create_email_logs.rb
index 9d04908bb87..cd59f899cd0 100644
--- a/db/migrate/20121011155904_create_email_logs.rb
+++ b/db/migrate/20121011155904_create_email_logs.rb
@@ -10,6 +10,6 @@ class CreateEmailLogs < ActiveRecord::Migration[4.2]
end
add_index :email_logs, :created_at, order: { created_at: :desc }
- add_index :email_logs, [:user_id, :created_at], order: { created_at: :desc }
+ add_index :email_logs, %i[user_id created_at], order: { created_at: :desc }
end
end
diff --git a/db/migrate/20121017162924_convert_archetypes.rb b/db/migrate/20121017162924_convert_archetypes.rb
index 891c413315b..8adce8204ab 100644
--- a/db/migrate/20121017162924_convert_archetypes.rb
+++ b/db/migrate/20121017162924_convert_archetypes.rb
@@ -2,7 +2,7 @@
class ConvertArchetypes < ActiveRecord::Migration[4.2]
def up
- add_column :forum_threads, :archetype, :string, default: 'regular', null: false
+ add_column :forum_threads, :archetype, :string, default: "regular", null: false
execute "UPDATE forum_threads SET archetype = a.name_key FROM archetypes AS a WHERE a.id = forum_threads.archetype_id"
remove_column :forum_threads, :archetype_id
diff --git a/db/migrate/20121018103721_rename_forum_thread_tables.rb b/db/migrate/20121018103721_rename_forum_thread_tables.rb
index cdcba0994f5..1b72b75cecc 100644
--- a/db/migrate/20121018103721_rename_forum_thread_tables.rb
+++ b/db/migrate/20121018103721_rename_forum_thread_tables.rb
@@ -2,39 +2,39 @@
class RenameForumThreadTables < ActiveRecord::Migration[4.2]
def change
- rename_table 'forum_threads', 'topics'
- rename_table 'forum_thread_link_clicks', 'topic_link_clicks'
- rename_table 'forum_thread_links', 'topic_links'
- rename_table 'forum_thread_users', 'topic_users'
- rename_table 'category_featured_threads', 'category_featured_topics'
+ rename_table "forum_threads", "topics"
+ rename_table "forum_thread_link_clicks", "topic_link_clicks"
+ rename_table "forum_thread_links", "topic_links"
+ rename_table "forum_thread_users", "topic_users"
+ rename_table "category_featured_threads", "category_featured_topics"
- rename_column 'categories', 'forum_thread_id', 'topic_id'
- rename_column 'categories', 'top1_forum_thread_id', 'top1_topic_id'
- rename_column 'categories', 'top2_forum_thread_id', 'top2_topic_id'
- rename_column 'categories', 'forum_thread_count', 'topic_count'
- rename_column 'categories', 'threads_year', 'topics_year'
- rename_column 'categories', 'threads_month', 'topics_month'
- rename_column 'categories', 'threads_week', 'topics_week'
+ rename_column "categories", "forum_thread_id", "topic_id"
+ rename_column "categories", "top1_forum_thread_id", "top1_topic_id"
+ rename_column "categories", "top2_forum_thread_id", "top2_topic_id"
+ rename_column "categories", "forum_thread_count", "topic_count"
+ rename_column "categories", "threads_year", "topics_year"
+ rename_column "categories", "threads_month", "topics_month"
+ rename_column "categories", "threads_week", "topics_week"
- rename_column 'category_featured_topics', 'forum_thread_id', 'topic_id'
+ rename_column "category_featured_topics", "forum_thread_id", "topic_id"
- rename_column 'topic_link_clicks', 'forum_thread_link_id', 'topic_link_id'
+ rename_column "topic_link_clicks", "forum_thread_link_id", "topic_link_id"
- rename_column 'topic_links', 'forum_thread_id', 'topic_id'
- rename_column 'topic_links', 'link_forum_thread_id', 'link_topic_id'
+ rename_column "topic_links", "forum_thread_id", "topic_id"
+ rename_column "topic_links", "link_forum_thread_id", "link_topic_id"
- rename_column 'topic_users', 'forum_thread_id', 'topic_id'
+ rename_column "topic_users", "forum_thread_id", "topic_id"
- rename_column 'incoming_links', 'forum_thread_id', 'topic_id'
+ rename_column "incoming_links", "forum_thread_id", "topic_id"
- rename_column 'notifications', 'forum_thread_id', 'topic_id'
+ rename_column "notifications", "forum_thread_id", "topic_id"
- rename_column 'post_timings', 'forum_thread_id', 'topic_id'
+ rename_column "post_timings", "forum_thread_id", "topic_id"
- rename_column 'posts', 'forum_thread_id', 'topic_id'
+ rename_column "posts", "forum_thread_id", "topic_id"
- rename_column 'user_actions', 'target_forum_thread_id', 'target_topic_id'
+ rename_column "user_actions", "target_forum_thread_id", "target_topic_id"
- rename_column 'uploads', 'forum_thread_id', 'topic_id'
+ rename_column "uploads", "forum_thread_id", "topic_id"
end
end
diff --git a/db/migrate/20121018133039_create_topic_allowed_users.rb b/db/migrate/20121018133039_create_topic_allowed_users.rb
index e926ae8fbc8..f6a996c4bd9 100644
--- a/db/migrate/20121018133039_create_topic_allowed_users.rb
+++ b/db/migrate/20121018133039_create_topic_allowed_users.rb
@@ -8,7 +8,7 @@ class CreateTopicAllowedUsers < ActiveRecord::Migration[4.2]
t.timestamps null: false
end
- add_index :topic_allowed_users, [:topic_id, :user_id], unique: true
- add_index :topic_allowed_users, [:user_id, :topic_id], unique: true
+ add_index :topic_allowed_users, %i[topic_id user_id], unique: true
+ add_index :topic_allowed_users, %i[user_id topic_id], unique: true
end
end
diff --git a/db/migrate/20121106015500_drop_avatar_url_from_users.rb b/db/migrate/20121106015500_drop_avatar_url_from_users.rb
index 1f27171727f..c8664801cd8 100644
--- a/db/migrate/20121106015500_drop_avatar_url_from_users.rb
+++ b/db/migrate/20121106015500_drop_avatar_url_from_users.rb
@@ -12,6 +12,6 @@ class DropAvatarUrlFromUsers < ActiveRecord::Migration[4.2]
end
def down
- add_column :users, :avatar_url, :string, null: false, default: ''
+ add_column :users, :avatar_url, :string, null: false, default: ""
end
end
diff --git a/db/migrate/20121121202035_create_invites.rb b/db/migrate/20121121202035_create_invites.rb
index 46096435ab4..3c36b8540eb 100644
--- a/db/migrate/20121121202035_create_invites.rb
+++ b/db/migrate/20121121202035_create_invites.rb
@@ -12,6 +12,6 @@ class CreateInvites < ActiveRecord::Migration[4.2]
end
add_index :invites, :invite_key, unique: true
- add_index :invites, [:email, :invited_by_id], unique: true
+ add_index :invites, %i[email invited_by_id], unique: true
end
end
diff --git a/db/migrate/20121121205215_create_topic_invites.rb b/db/migrate/20121121205215_create_topic_invites.rb
index 5ff307a5af3..f0156b34351 100644
--- a/db/migrate/20121121205215_create_topic_invites.rb
+++ b/db/migrate/20121121205215_create_topic_invites.rb
@@ -8,7 +8,7 @@ class CreateTopicInvites < ActiveRecord::Migration[4.2]
t.timestamps null: false
end
- add_index :topic_invites, [:topic_id, :invite_id], unique: true
+ add_index :topic_invites, %i[topic_id invite_id], unique: true
add_index :topic_invites, :invite_id
end
end
diff --git a/db/migrate/20121123054127_make_post_number_distinct.rb b/db/migrate/20121123054127_make_post_number_distinct.rb
index 0270daec474..c8dfba51ddc 100644
--- a/db/migrate/20121123054127_make_post_number_distinct.rb
+++ b/db/migrate/20121123054127_make_post_number_distinct.rb
@@ -2,8 +2,8 @@
class MakePostNumberDistinct < ActiveRecord::Migration[4.2]
def up
-
- DB.exec('update posts p
+ DB.exec(
+ "update posts p
set post_number = calc
from
(
@@ -20,7 +20,8 @@ from
)
) as X
-where calc <> p.post_number and X.id = p.id')
+where calc <> p.post_number and X.id = p.id",
+ )
end
def down
diff --git a/db/migrate/20121123063630_create_user_visits.rb b/db/migrate/20121123063630_create_user_visits.rb
index 994ea22d525..85f9eaca8b5 100644
--- a/db/migrate/20121123063630_create_user_visits.rb
+++ b/db/migrate/20121123063630_create_user_visits.rb
@@ -7,6 +7,6 @@ class CreateUserVisits < ActiveRecord::Migration[4.2]
t.date :visited_at, null: false
end
- add_index :user_visits, [:user_id, :visited_at], unique: true
+ add_index :user_visits, %i[user_id visited_at], unique: true
end
end
diff --git a/db/migrate/20121130010400_create_drafts.rb b/db/migrate/20121130010400_create_drafts.rb
index 6d5bfe17235..5ae257ff725 100644
--- a/db/migrate/20121130010400_create_drafts.rb
+++ b/db/migrate/20121130010400_create_drafts.rb
@@ -8,6 +8,6 @@ class CreateDrafts < ActiveRecord::Migration[4.2]
t.text :data, null: false
t.timestamps null: false
end
- add_index :drafts, [:user_id, :draft_key]
+ add_index :drafts, %i[user_id draft_key]
end
end
diff --git a/db/migrate/20121204183855_fix_link_post_id.rb b/db/migrate/20121204183855_fix_link_post_id.rb
index 2fe158b6079..bc99f99baa3 100644
--- a/db/migrate/20121204183855_fix_link_post_id.rb
+++ b/db/migrate/20121204183855_fix_link_post_id.rb
@@ -4,22 +4,21 @@ class FixLinkPostId < ActiveRecord::Migration[4.2]
def up
to_remove = []
- TopicLink.where('internal = TRUE AND link_post_id IS NULL').each do |tl|
-
- begin
- parsed = URI.parse(tl.url)
- route = Rails.application.routes.recognize_path(parsed.path)
- if route[:topic_id].present?
- post = Post.find_by(topic_id: route[:topic_id], post_number: (route[:post_number] || 1))
- tl.update_column(:link_post_id, post.id) if post.present?
+ TopicLink
+ .where("internal = TRUE AND link_post_id IS NULL")
+ .each do |tl|
+ begin
+ parsed = URI.parse(tl.url)
+ route = Rails.application.routes.recognize_path(parsed.path)
+ if route[:topic_id].present?
+ post = Post.find_by(topic_id: route[:topic_id], post_number: (route[:post_number] || 1))
+ tl.update_column(:link_post_id, post.id) if post.present?
+ end
+ rescue ActionController::RoutingError
+ to_remove << tl.id
end
-
- rescue ActionController::RoutingError
- to_remove << tl.id
end
- end
-
TopicLink.where("id in (?)", to_remove).delete_all
end
diff --git a/db/migrate/20121216230719_add_override_default_style_to_site_customization.rb b/db/migrate/20121216230719_add_override_default_style_to_site_customization.rb
index 4bab4d6e007..2dd399adb0e 100644
--- a/db/migrate/20121216230719_add_override_default_style_to_site_customization.rb
+++ b/db/migrate/20121216230719_add_override_default_style_to_site_customization.rb
@@ -3,6 +3,6 @@
class AddOverrideDefaultStyleToSiteCustomization < ActiveRecord::Migration[4.2]
def change
add_column :site_customizations, :override_default_style, :boolean, default: false, null: false
- add_column :site_customizations, :stylesheet_baked, :text, default: '', null: false
+ add_column :site_customizations, :stylesheet_baked, :text, default: "", null: false
end
end
diff --git a/db/migrate/20121224095139_create_draft_sequence.rb b/db/migrate/20121224095139_create_draft_sequence.rb
index fbd32d4a842..ae996eb7104 100644
--- a/db/migrate/20121224095139_create_draft_sequence.rb
+++ b/db/migrate/20121224095139_create_draft_sequence.rb
@@ -7,6 +7,6 @@ class CreateDraftSequence < ActiveRecord::Migration[4.2]
t.string :draft_key, null: false
t.integer :sequence, null: false
end
- add_index :draft_sequences, [:user_id, :draft_key], unique: true
+ add_index :draft_sequences, %i[user_id draft_key], unique: true
end
end
diff --git a/db/migrate/20130115043603_oops_unwatch_a_boat_of_watched_stuff.rb b/db/migrate/20130115043603_oops_unwatch_a_boat_of_watched_stuff.rb
index d793092f440..43af27d0c4f 100644
--- a/db/migrate/20130115043603_oops_unwatch_a_boat_of_watched_stuff.rb
+++ b/db/migrate/20130115043603_oops_unwatch_a_boat_of_watched_stuff.rb
@@ -2,6 +2,6 @@
class OopsUnwatchABoatOfWatchedStuff < ActiveRecord::Migration[4.2]
def change
- execute 'update topic_users set notification_level = 1 where notifications_reason_id is null and notification_level = 2'
+ execute "update topic_users set notification_level = 1 where notifications_reason_id is null and notification_level = 2"
end
end
diff --git a/db/migrate/20130120222728_fix_search.rb b/db/migrate/20130120222728_fix_search.rb
index 48e775fb7ea..8e449bbd850 100644
--- a/db/migrate/20130120222728_fix_search.rb
+++ b/db/migrate/20130120222728_fix_search.rb
@@ -2,16 +2,16 @@
class FixSearch < ActiveRecord::Migration[4.2]
def up
- execute 'drop index idx_search_thread'
- execute 'drop index idx_search_user'
+ execute "drop index idx_search_thread"
+ execute "drop index idx_search_user"
- execute 'create table posts_search (id integer not null primary key, search_data tsvector)'
- execute 'create table users_search (id integer not null primary key, search_data tsvector)'
- execute 'create table categories_search (id integer not null primary key, search_data tsvector)'
+ execute "create table posts_search (id integer not null primary key, search_data tsvector)"
+ execute "create table users_search (id integer not null primary key, search_data tsvector)"
+ execute "create table categories_search (id integer not null primary key, search_data tsvector)"
- execute 'create index idx_search_post on posts_search using gin(search_data) '
- execute 'create index idx_search_user on users_search using gin(search_data) '
- execute 'create index idx_search_category on categories_search using gin(search_data) '
+ execute "create index idx_search_post on posts_search using gin(search_data) "
+ execute "create index idx_search_user on users_search using gin(search_data) "
+ execute "create index idx_search_category on categories_search using gin(search_data) "
end
def down
diff --git a/db/migrate/20130121231352_add_tracking_to_topic_users.rb b/db/migrate/20130121231352_add_tracking_to_topic_users.rb
index 78173e3b6bb..5ebe50af33f 100644
--- a/db/migrate/20130121231352_add_tracking_to_topic_users.rb
+++ b/db/migrate/20130121231352_add_tracking_to_topic_users.rb
@@ -2,9 +2,9 @@
class AddTrackingToTopicUsers < ActiveRecord::Migration[4.2]
def up
- execute 'update topic_users set notification_level = 3 where notification_level = 2'
+ execute "update topic_users set notification_level = 3 where notification_level = 2"
end
def down
- execute 'update topic_users set notification_level = 2 where notification_level = 3'
+ execute "update topic_users set notification_level = 2 where notification_level = 3"
end
end
diff --git a/db/migrate/20130122232825_add_auto_track_after_seconds_and_banning_and_dob_to_user.rb b/db/migrate/20130122232825_add_auto_track_after_seconds_and_banning_and_dob_to_user.rb
index 10bc0fe2098..fc6eea34b6b 100644
--- a/db/migrate/20130122232825_add_auto_track_after_seconds_and_banning_and_dob_to_user.rb
+++ b/db/migrate/20130122232825_add_auto_track_after_seconds_and_banning_and_dob_to_user.rb
@@ -12,11 +12,11 @@ class AddAutoTrackAfterSecondsAndBanningAndDobToUser < ActiveRecord::Migration[4
add_column :topic_users, :total_msecs_viewed, :integer, null: false, default: 0
- execute 'update topic_users set total_msecs_viewed =
+ execute "update topic_users set total_msecs_viewed =
(
select coalesce(sum(msecs) ,0)
from post_timings t
where topic_users.topic_id = t.topic_id and topic_users.user_id = t.user_id
- )'
+ )"
end
end
diff --git a/db/migrate/20130123070909_auto_track_all_topics_replied_to.rb b/db/migrate/20130123070909_auto_track_all_topics_replied_to.rb
index 35ff0e57e14..d0ec9ebd5cf 100644
--- a/db/migrate/20130123070909_auto_track_all_topics_replied_to.rb
+++ b/db/migrate/20130123070909_auto_track_all_topics_replied_to.rb
@@ -2,14 +2,14 @@
class AutoTrackAllTopicsRepliedTo < ActiveRecord::Migration[4.2]
def up
- execute 'update topic_users set notification_level = 2, notifications_reason_id = 4
+ execute "update topic_users set notification_level = 2, notifications_reason_id = 4
from posts p
where
notification_level = 1 and
notifications_reason_id is null and
p.topic_id = topic_users.topic_id and
p.user_id = topic_users.user_id
- '
+ "
end
def down
diff --git a/db/migrate/20130125031122_correct_index_on_post_action.rb b/db/migrate/20130125031122_correct_index_on_post_action.rb
index 3f947d4b428..3237a635e35 100644
--- a/db/migrate/20130125031122_correct_index_on_post_action.rb
+++ b/db/migrate/20130125031122_correct_index_on_post_action.rb
@@ -3,6 +3,9 @@
class CorrectIndexOnPostAction < ActiveRecord::Migration[4.2]
def change
remove_index "post_actions", name: "idx_unique_actions"
- add_index "post_actions", ["user_id", "post_action_type_id", "post_id", "deleted_at"], name: "idx_unique_actions", unique: true
+ add_index "post_actions",
+ %w[user_id post_action_type_id post_id deleted_at],
+ name: "idx_unique_actions",
+ unique: true
end
end
diff --git a/db/migrate/20130127213646_remove_trust_levels.rb b/db/migrate/20130127213646_remove_trust_levels.rb
index 2154d2ac0a0..0e7fea2b71f 100644
--- a/db/migrate/20130127213646_remove_trust_levels.rb
+++ b/db/migrate/20130127213646_remove_trust_levels.rb
@@ -11,5 +11,4 @@ class RemoveTrustLevels < ActiveRecord::Migration[4.2]
remove_column :users, :moderator
add_column :users, :flag_level, :integer, null: false, default: 0
end
-
end
diff --git a/db/migrate/20130130154611_remove_index_from_views.rb b/db/migrate/20130130154611_remove_index_from_views.rb
index 4af6cede796..bfa93c0575a 100644
--- a/db/migrate/20130130154611_remove_index_from_views.rb
+++ b/db/migrate/20130130154611_remove_index_from_views.rb
@@ -7,7 +7,7 @@ class RemoveIndexFromViews < ActiveRecord::Migration[4.2]
end
def down
- add_index "views", ["parent_id", "parent_type", "ip", "viewed_at"], name: "unique_views", unique: true
+ add_index "views", %w[parent_id parent_type ip viewed_at], name: "unique_views", unique: true
change_column :views, :viewed_at, :timestamp
end
end
diff --git a/db/migrate/20130204000159_add_ip_address_to_users.rb b/db/migrate/20130204000159_add_ip_address_to_users.rb
index 6ac3e4b9299..9fab5fefa7e 100644
--- a/db/migrate/20130204000159_add_ip_address_to_users.rb
+++ b/db/migrate/20130204000159_add_ip_address_to_users.rb
@@ -2,9 +2,9 @@
class AddIpAddressToUsers < ActiveRecord::Migration[4.2]
def up
- execute 'alter table users add column ip_address inet'
+ execute "alter table users add column ip_address inet"
end
def down
- execute 'alter table users drop column ip_address'
+ execute "alter table users drop column ip_address"
end
end
diff --git a/db/migrate/20130213021450_remove_topic_response_actions.rb b/db/migrate/20130213021450_remove_topic_response_actions.rb
index 2709734c8ec..cf425a2abd2 100644
--- a/db/migrate/20130213021450_remove_topic_response_actions.rb
+++ b/db/migrate/20130213021450_remove_topic_response_actions.rb
@@ -8,7 +8,7 @@ class RemoveTopicResponseActions < ActiveRecord::Migration[4.2]
#
# There is an open question about we should keep stuff in the user stream on the user page, even if a topic is unwatched
# Eg: I am not watching a topic I created, when somebody responds to the topic should I be notified on the user page?
- execute 'delete from user_actions where action_type = 8'
+ execute "delete from user_actions where action_type = 8"
end
def down
diff --git a/db/migrate/20130221215017_add_description_to_categories.rb b/db/migrate/20130221215017_add_description_to_categories.rb
index f7b3071e6c3..3f6a2a2fee5 100644
--- a/db/migrate/20130221215017_add_description_to_categories.rb
+++ b/db/migrate/20130221215017_add_description_to_categories.rb
@@ -13,23 +13,22 @@ class AddDescriptionToCategories < ActiveRecord::Migration[4.2]
# some ancient installs may have bad category descriptions
# attempt to fix
if !DB.query_single("SELECT 1 FROM categories limit 1").empty?
-
# Reaching into post revisor is not ideal here, but this code
# should almost never run, so bypass it
Discourse.reset_active_record_cache
- Category.order('id').each do |c|
- post = c.topic.ordered_posts.first
- PostRevisor.new(post).update_category_description
- end
+ Category
+ .order("id")
+ .each do |c|
+ post = c.topic.ordered_posts.first
+ PostRevisor.new(post).update_category_description
+ end
Discourse.reset_active_record_cache
end
-
end
def down
remove_column :categories, :description
end
-
end
diff --git a/db/migrate/20130226015336_add_github_user_info.rb b/db/migrate/20130226015336_add_github_user_info.rb
index edcfacea250..3f0d956e6ad 100644
--- a/db/migrate/20130226015336_add_github_user_info.rb
+++ b/db/migrate/20130226015336_add_github_user_info.rb
@@ -2,7 +2,7 @@
class AddGithubUserInfo < ActiveRecord::Migration[4.2]
def change
- create_table :github_user_infos do |t|
+ create_table :github_user_infos do |t|
t.integer :user_id, null: false
t.string :screen_name, null: false
t.integer :github_user_id, null: false
diff --git a/db/migrate/20130314093434_add_foreground_color_to_categories.rb b/db/migrate/20130314093434_add_foreground_color_to_categories.rb
index 1784d7785d9..72508e2411c 100644
--- a/db/migrate/20130314093434_add_foreground_color_to_categories.rb
+++ b/db/migrate/20130314093434_add_foreground_color_to_categories.rb
@@ -2,6 +2,6 @@
class AddForegroundColorToCategories < ActiveRecord::Migration[4.2]
def change
- add_column :categories, :text_color, :string, limit: 6, null: false, default: 'FFFFFF'
+ add_column :categories, :text_color, :string, limit: 6, null: false, default: "FFFFFF"
end
end
diff --git a/db/migrate/20130319122248_add_reply_to_user_id_to_post.rb b/db/migrate/20130319122248_add_reply_to_user_id_to_post.rb
index 62aec7d5317..0eab8603229 100644
--- a/db/migrate/20130319122248_add_reply_to_user_id_to_post.rb
+++ b/db/migrate/20130319122248_add_reply_to_user_id_to_post.rb
@@ -4,12 +4,12 @@ class AddReplyToUserIdToPost < ActiveRecord::Migration[4.2]
def up
# caching this column makes the topic page WAY faster
add_column :posts, :reply_to_user_id, :integer
- execute 'UPDATE posts p SET reply_to_user_id = (
+ execute "UPDATE posts p SET reply_to_user_id = (
SELECT u.id from users u
JOIN posts p2 ON p2.user_id = u.id AND
p2.post_number = p.reply_to_post_number AND
p2.topic_id = p.topic_id
- )'
+ )"
end
def down
diff --git a/db/migrate/20130322183614_add_percent_rank_to_posts.rb b/db/migrate/20130322183614_add_percent_rank_to_posts.rb
index 93e861cee57..cfa2a8c5f58 100644
--- a/db/migrate/20130322183614_add_percent_rank_to_posts.rb
+++ b/db/migrate/20130322183614_add_percent_rank_to_posts.rb
@@ -9,6 +9,5 @@ class AddPercentRankToPosts < ActiveRecord::Migration[4.2]
OVER (PARTITION BY topic_id ORDER BY SCORE DESC)
FROM posts) AS x
WHERE x.id = posts.id"
-
end
end
diff --git a/db/migrate/20130328162943_create_hot_topics.rb b/db/migrate/20130328162943_create_hot_topics.rb
index e574da1aea8..2bdd873dbaf 100644
--- a/db/migrate/20130328162943_create_hot_topics.rb
+++ b/db/migrate/20130328162943_create_hot_topics.rb
@@ -9,6 +9,6 @@ class CreateHotTopics < ActiveRecord::Migration[4.2]
end
add_index :hot_topics, :topic_id, unique: true
- add_index :hot_topics, :score, order: 'desc'
+ add_index :hot_topics, :score, order: "desc"
end
end
diff --git a/db/migrate/20130404232558_add_user_extras.rb b/db/migrate/20130404232558_add_user_extras.rb
index 8fc2c776af7..6e0401ec338 100644
--- a/db/migrate/20130404232558_add_user_extras.rb
+++ b/db/migrate/20130404232558_add_user_extras.rb
@@ -2,7 +2,6 @@
class AddUserExtras < ActiveRecord::Migration[4.2]
def up
-
# NOTE: our user table is getting bloated, we probably want to split it for performance
# put lesser used columns into a user_extras table and frequently used ones here.
add_column :users, :likes_given, :integer, null: false, default: 0
@@ -27,7 +26,7 @@ FROM (
WHERE X.user_id = u.id
SQL
- execute <<SQL
+ execute <<SQL
UPDATE users u
SET
likes_received = Y.likes_received
@@ -43,7 +42,7 @@ FROM (
WHERE Y.user_id = u.id
SQL
- execute <<SQL
+ execute <<SQL
UPDATE users u
SET
topic_reply_count = Z.topic_reply_count
@@ -60,7 +59,6 @@ FROM (
WHERE
Z.user_id = u.id
SQL
-
end
def down
diff --git a/db/migrate/20130411205132_create_admin_logs.rb b/db/migrate/20130411205132_create_admin_logs.rb
index 2be90129ad0..8d8cde290a4 100644
--- a/db/migrate/20130411205132_create_admin_logs.rb
+++ b/db/migrate/20130411205132_create_admin_logs.rb
@@ -3,10 +3,10 @@
class CreateAdminLogs < ActiveRecord::Migration[4.2]
def up
create_table :admin_logs, force: true do |t|
- t.integer :action, null: false
- t.integer :admin_id, null: false
+ t.integer :action, null: false
+ t.integer :admin_id, null: false
t.integer :target_user_id
- t.text :details
+ t.text :details
t.timestamps null: false
end
end
diff --git a/db/migrate/20130416004933_group_users.rb b/db/migrate/20130416004933_group_users.rb
index fb405a4f3aa..bbb38dcd6c6 100644
--- a/db/migrate/20130416004933_group_users.rb
+++ b/db/migrate/20130416004933_group_users.rb
@@ -8,6 +8,6 @@ class GroupUsers < ActiveRecord::Migration[4.2]
t.timestamps null: false
end
- add_index :group_users, [:group_id, :user_id], unique: true
+ add_index :group_users, %i[group_id user_id], unique: true
end
end
diff --git a/db/migrate/20130430052751_add_topic_allowed_groups.rb b/db/migrate/20130430052751_add_topic_allowed_groups.rb
index aae17685c61..6e75bc6e403 100644
--- a/db/migrate/20130430052751_add_topic_allowed_groups.rb
+++ b/db/migrate/20130430052751_add_topic_allowed_groups.rb
@@ -8,7 +8,7 @@ class AddTopicAllowedGroups < ActiveRecord::Migration[4.2]
t.integer :topic_id, null: false
end
- add_index :topic_allowed_groups, [:group_id, :topic_id], unique: true
- add_index :topic_allowed_groups, [:topic_id, :group_id], unique: true
+ add_index :topic_allowed_groups, %i[group_id topic_id], unique: true
+ add_index :topic_allowed_groups, %i[topic_id group_id], unique: true
end
end
diff --git a/db/migrate/20130506185042_add_auto_close_at_to_topics.rb b/db/migrate/20130506185042_add_auto_close_at_to_topics.rb
index fe7322baec1..6a99ea9bf8b 100644
--- a/db/migrate/20130506185042_add_auto_close_at_to_topics.rb
+++ b/db/migrate/20130506185042_add_auto_close_at_to_topics.rb
@@ -2,7 +2,7 @@
class AddAutoCloseAtToTopics < ActiveRecord::Migration[4.2]
def change
- add_column :topics, :auto_close_at, :datetime
+ add_column :topics, :auto_close_at, :datetime
add_column :topics, :auto_close_user_id, :integer
end
end
diff --git a/db/migrate/20130528174147_add_rank_to_category_featured_topics.rb b/db/migrate/20130528174147_add_rank_to_category_featured_topics.rb
index a1dacf74ef0..7c44f6dba3a 100644
--- a/db/migrate/20130528174147_add_rank_to_category_featured_topics.rb
+++ b/db/migrate/20130528174147_add_rank_to_category_featured_topics.rb
@@ -3,6 +3,6 @@
class AddRankToCategoryFeaturedTopics < ActiveRecord::Migration[4.2]
def change
add_column :category_featured_topics, :rank, :integer, default: 0, null: false
- add_index :category_featured_topics, [:category_id, :rank]
+ add_index :category_featured_topics, %i[category_id rank]
end
end
diff --git a/db/migrate/20130612200846_create_post_upload_join_table.rb b/db/migrate/20130612200846_create_post_upload_join_table.rb
index dce05c426f7..873f29e8163 100644
--- a/db/migrate/20130612200846_create_post_upload_join_table.rb
+++ b/db/migrate/20130612200846_create_post_upload_join_table.rb
@@ -9,6 +9,6 @@ class CreatePostUploadJoinTable < ActiveRecord::Migration[4.2]
add_index :posts_uploads, :post_id
add_index :posts_uploads, :upload_id
- add_index :posts_uploads, [:post_id, :upload_id], unique: true
+ add_index :posts_uploads, %i[post_id upload_id], unique: true
end
end
diff --git a/db/migrate/20130613211700_drop_posts_uploads.rb b/db/migrate/20130613211700_drop_posts_uploads.rb
index 3998c754564..2f5ddde7218 100644
--- a/db/migrate/20130613211700_drop_posts_uploads.rb
+++ b/db/migrate/20130613211700_drop_posts_uploads.rb
@@ -13,6 +13,6 @@ class DropPostsUploads < ActiveRecord::Migration[4.2]
add_index :posts_uploads, :post_id
add_index :posts_uploads, :upload_id
- add_index :posts_uploads, [:post_id, :upload_id], unique: true
+ add_index :posts_uploads, %i[post_id upload_id], unique: true
end
end
diff --git a/db/migrate/20130613212230_create_post_uploads.rb b/db/migrate/20130613212230_create_post_uploads.rb
index 088384b3bfe..d3cf72dd604 100644
--- a/db/migrate/20130613212230_create_post_uploads.rb
+++ b/db/migrate/20130613212230_create_post_uploads.rb
@@ -8,7 +8,7 @@ class CreatePostUploads < ActiveRecord::Migration[4.2]
end
# no support for this till rails 4
- execute 'create unique index idx_unique_post_uploads on post_uploads(post_id, upload_id)'
+ execute "create unique index idx_unique_post_uploads on post_uploads(post_id, upload_id)"
end
def down
diff --git a/db/migrate/20130616082327_create_optimized_images.rb b/db/migrate/20130616082327_create_optimized_images.rb
index ef8272a03d0..6b839c7dd64 100644
--- a/db/migrate/20130616082327_create_optimized_images.rb
+++ b/db/migrate/20130616082327_create_optimized_images.rb
@@ -11,7 +11,7 @@ class CreateOptimizedImages < ActiveRecord::Migration[4.2]
end
add_index :optimized_images, :upload_id
- add_index :optimized_images, [:upload_id, :width, :height], unique: true
+ add_index :optimized_images, %i[upload_id width height], unique: true
end
def down
diff --git a/db/migrate/20130621042855_change_supress_to_suppress.rb b/db/migrate/20130621042855_change_supress_to_suppress.rb
index cc4dc12fe45..1ebba70ebc1 100644
--- a/db/migrate/20130621042855_change_supress_to_suppress.rb
+++ b/db/migrate/20130621042855_change_supress_to_suppress.rb
@@ -2,10 +2,14 @@
class ChangeSupressToSuppress < ActiveRecord::Migration[4.2]
def up
- SiteSetting.where(name: "suppress_reply_directly_below").update_all(name: "supress_reply_directly_below")
+ SiteSetting.where(name: "suppress_reply_directly_below").update_all(
+ name: "supress_reply_directly_below",
+ )
end
def down
- SiteSetting.where(name: "supress_reply_directly_below").update_all(name: "suppress_reply_directly_below")
+ SiteSetting.where(name: "supress_reply_directly_below").update_all(
+ name: "suppress_reply_directly_below",
+ )
end
end
diff --git a/db/migrate/20130624203206_change_ip_to_inet_in_topic_link_clicks.rb b/db/migrate/20130624203206_change_ip_to_inet_in_topic_link_clicks.rb
index 40c6de2172f..91778b8f1b0 100644
--- a/db/migrate/20130624203206_change_ip_to_inet_in_topic_link_clicks.rb
+++ b/db/migrate/20130624203206_change_ip_to_inet_in_topic_link_clicks.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'ipaddr'
+require "ipaddr"
class ChangeIpToInetInTopicLinkClicks < ActiveRecord::Migration[4.2]
def up
diff --git a/db/migrate/20130625022454_change_ip_to_inet_in_views.rb b/db/migrate/20130625022454_change_ip_to_inet_in_views.rb
index 050f57ab8f8..e0d80d57cb8 100644
--- a/db/migrate/20130625022454_change_ip_to_inet_in_views.rb
+++ b/db/migrate/20130625022454_change_ip_to_inet_in_views.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'ipaddr'
+require "ipaddr"
class ChangeIpToInetInViews < ActiveRecord::Migration[4.2]
def up
diff --git a/db/migrate/20130625170842_remove_access_password.rb b/db/migrate/20130625170842_remove_access_password.rb
index 40a8fab27b9..9b4da8619b0 100644
--- a/db/migrate/20130625170842_remove_access_password.rb
+++ b/db/migrate/20130625170842_remove_access_password.rb
@@ -2,7 +2,10 @@
class RemoveAccessPassword < ActiveRecord::Migration[4.2]
def up
- result = execute("SELECT count(*) FROM site_settings where name='access_password' and char_length(value) > 0")
+ result =
+ execute(
+ "SELECT count(*) FROM site_settings where name='access_password' and char_length(value) > 0",
+ )
if result[0] && result[0]["count"].to_i > (0)
execute "DELETE FROM site_settings where name='access_password'"
SiteSetting.login_required = true
diff --git a/db/migrate/20130731163035_add_report_index_to_incoming_links.rb b/db/migrate/20130731163035_add_report_index_to_incoming_links.rb
index 6f6e5711ef3..adfe13d8dc8 100644
--- a/db/migrate/20130731163035_add_report_index_to_incoming_links.rb
+++ b/db/migrate/20130731163035_add_report_index_to_incoming_links.rb
@@ -2,7 +2,7 @@
class AddReportIndexToIncomingLinks < ActiveRecord::Migration[4.2]
def change
- add_index :incoming_links, [:created_at, :user_id]
- add_index :incoming_links, [:created_at, :domain]
+ add_index :incoming_links, %i[created_at user_id]
+ add_index :incoming_links, %i[created_at domain]
end
end
diff --git a/db/migrate/20130809160751_fix_seen_notification_ids.rb b/db/migrate/20130809160751_fix_seen_notification_ids.rb
index b002ec486fb..feda358e662 100644
--- a/db/migrate/20130809160751_fix_seen_notification_ids.rb
+++ b/db/migrate/20130809160751_fix_seen_notification_ids.rb
@@ -2,7 +2,6 @@
class FixSeenNotificationIds < ActiveRecord::Migration[4.2]
def up
-
# There was an error where `seen_notification_id` was being updated incorrectly.
# This tries to fix some of the bad data.
execute "UPDATE users SET
diff --git a/db/migrate/20130809204732_add_filter_indexes_to_staff_action_logs.rb b/db/migrate/20130809204732_add_filter_indexes_to_staff_action_logs.rb
index 2a559646bd9..479a4305b42 100644
--- a/db/migrate/20130809204732_add_filter_indexes_to_staff_action_logs.rb
+++ b/db/migrate/20130809204732_add_filter_indexes_to_staff_action_logs.rb
@@ -2,8 +2,8 @@
class AddFilterIndexesToStaffActionLogs < ActiveRecord::Migration[4.2]
def change
- add_index :staff_action_logs, [:action, :id]
- add_index :staff_action_logs, [:staff_user_id, :id]
- add_index :staff_action_logs, [:target_user_id, :id]
+ add_index :staff_action_logs, %i[action id]
+ add_index :staff_action_logs, %i[staff_user_id id]
+ add_index :staff_action_logs, %i[target_user_id id]
end
end
diff --git a/db/migrate/20130816024250_create_oauth2_user_infos.rb b/db/migrate/20130816024250_create_oauth2_user_infos.rb
index daea47c31f1..efcaea23ea7 100644
--- a/db/migrate/20130816024250_create_oauth2_user_infos.rb
+++ b/db/migrate/20130816024250_create_oauth2_user_infos.rb
@@ -11,6 +11,6 @@ class CreateOauth2UserInfos < ActiveRecord::Migration[4.2]
t.timestamps null: false
end
- add_index :oauth2_user_infos, [:uid, :provider], unique: true
+ add_index :oauth2_user_infos, %i[uid provider], unique: true
end
end
diff --git a/db/migrate/20130820174431_add_subject_index_to_staff_action_logs.rb b/db/migrate/20130820174431_add_subject_index_to_staff_action_logs.rb
index b9aae2d4696..9111b296c6a 100644
--- a/db/migrate/20130820174431_add_subject_index_to_staff_action_logs.rb
+++ b/db/migrate/20130820174431_add_subject_index_to_staff_action_logs.rb
@@ -2,6 +2,6 @@
class AddSubjectIndexToStaffActionLogs < ActiveRecord::Migration[4.2]
def change
- add_index :staff_action_logs, [:subject, :id]
+ add_index :staff_action_logs, %i[subject id]
end
end
diff --git a/db/migrate/20130822213513_add_ip_address_to_screening_tables.rb b/db/migrate/20130822213513_add_ip_address_to_screening_tables.rb
index f226f18b2f3..1ac091bacd1 100644
--- a/db/migrate/20130822213513_add_ip_address_to_screening_tables.rb
+++ b/db/migrate/20130822213513_add_ip_address_to_screening_tables.rb
@@ -3,6 +3,6 @@
class AddIpAddressToScreeningTables < ActiveRecord::Migration[4.2]
def change
add_column :screened_emails, :ip_address, :inet
- add_column :screened_urls, :ip_address, :inet
+ add_column :screened_urls, :ip_address, :inet
end
end
diff --git a/db/migrate/20130823201420_drop_defaults_on_email_digest_columns_of_users.rb b/db/migrate/20130823201420_drop_defaults_on_email_digest_columns_of_users.rb
index f1f3560dd48..1abbc0d1267 100644
--- a/db/migrate/20130823201420_drop_defaults_on_email_digest_columns_of_users.rb
+++ b/db/migrate/20130823201420_drop_defaults_on_email_digest_columns_of_users.rb
@@ -2,13 +2,13 @@
class DropDefaultsOnEmailDigestColumnsOfUsers < ActiveRecord::Migration[4.2]
def up
- change_column_default :users, :email_digests, nil
- change_column :users, :digest_after_days, :integer, default: nil, null: true
+ change_column_default :users, :email_digests, nil
+ change_column :users, :digest_after_days, :integer, default: nil, null: true
end
def down
- change_column_default :users, :email_digests, true
+ change_column_default :users, :email_digests, true
change_column_default :users, :digest_after_days, 7
- change_column :users, :digest_after_days, :integer, default: 7, null: false
+ change_column :users, :digest_after_days, :integer, default: 7, null: false
end
end
diff --git a/db/migrate/20130826011521_create_plugin_store_rows.rb b/db/migrate/20130826011521_create_plugin_store_rows.rb
index f74a9037d9a..c8190d750fc 100644
--- a/db/migrate/20130826011521_create_plugin_store_rows.rb
+++ b/db/migrate/20130826011521_create_plugin_store_rows.rb
@@ -12,6 +12,6 @@ class CreatePluginStoreRows < ActiveRecord::Migration[4.2]
table.text :value
end
- add_index :plugin_store_rows, [:plugin_name, :key], unique: true
+ add_index :plugin_store_rows, %i[plugin_name key], unique: true
end
end
diff --git a/db/migrate/20130903154323_allow_null_user_id_on_posts.rb b/db/migrate/20130903154323_allow_null_user_id_on_posts.rb
index 0798b0debf3..27d474618b5 100644
--- a/db/migrate/20130903154323_allow_null_user_id_on_posts.rb
+++ b/db/migrate/20130903154323_allow_null_user_id_on_posts.rb
@@ -8,7 +8,7 @@ class AllowNullUserIdOnPosts < ActiveRecord::Migration[4.2]
end
def down
- add_column :posts, :nuked_user, :boolean, default: false
+ add_column :posts, :nuked_user, :boolean, default: false
change_column :posts, :user_id, :integer, null: false
end
end
diff --git a/db/migrate/20130906171631_add_index_to_uploads.rb b/db/migrate/20130906171631_add_index_to_uploads.rb
index ad15cd3bc93..293f81b6209 100644
--- a/db/migrate/20130906171631_add_index_to_uploads.rb
+++ b/db/migrate/20130906171631_add_index_to_uploads.rb
@@ -2,6 +2,6 @@
class AddIndexToUploads < ActiveRecord::Migration[4.2]
def change
- add_index :uploads, [:id, :url]
+ add_index :uploads, %i[id url]
end
end
diff --git a/db/migrate/20130910040235_index_topics_for_front_page.rb b/db/migrate/20130910040235_index_topics_for_front_page.rb
index 746e7946fa2..1717580d6ea 100644
--- a/db/migrate/20130910040235_index_topics_for_front_page.rb
+++ b/db/migrate/20130910040235_index_topics_for_front_page.rb
@@ -2,9 +2,8 @@
class IndexTopicsForFrontPage < ActiveRecord::Migration[4.2]
def change
- add_index :topics, [:deleted_at, :visible, :archetype, :id]
+ add_index :topics, %i[deleted_at visible archetype id]
# covering index for join
- add_index :topics, [:id, :deleted_at]
+ add_index :topics, %i[id deleted_at]
end
-
end
diff --git a/db/migrate/20130910220317_rename_staff_action_logs_to_user_history.rb b/db/migrate/20130910220317_rename_staff_action_logs_to_user_history.rb
index acd5f730c79..34894ba3264 100644
--- a/db/migrate/20130910220317_rename_staff_action_logs_to_user_history.rb
+++ b/db/migrate/20130910220317_rename_staff_action_logs_to_user_history.rb
@@ -2,16 +2,16 @@
class RenameStaffActionLogsToUserHistory < ActiveRecord::Migration[4.2]
def up
- remove_index :staff_action_logs, [:staff_user_id, :id]
+ remove_index :staff_action_logs, %i[staff_user_id id]
rename_table :staff_action_logs, :user_histories
rename_column :user_histories, :staff_user_id, :acting_user_id
- add_index :user_histories, [:acting_user_id, :action, :id]
+ add_index :user_histories, %i[acting_user_id action id]
end
def down
- remove_index :user_histories, [:acting_user_id, :action, :id]
+ remove_index :user_histories, %i[acting_user_id action id]
rename_table :user_histories, :staff_action_logs
rename_column :staff_action_logs, :acting_user_id, :staff_user_id
- add_index :staff_action_logs, [:staff_user_id, :id]
+ add_index :staff_action_logs, %i[staff_user_id id]
end
end
diff --git a/db/migrate/20130911182437_create_user_stats.rb b/db/migrate/20130911182437_create_user_stats.rb
index 9b0794e8aaf..9a89a9254d9 100644
--- a/db/migrate/20130911182437_create_user_stats.rb
+++ b/db/migrate/20130911182437_create_user_stats.rb
@@ -13,5 +13,4 @@ class CreateUserStats < ActiveRecord::Migration[4.2]
def down
drop_table :user_stats
end
-
end
diff --git a/db/migrate/20131002070347_add_user_id_parent_type_index_on_views.rb b/db/migrate/20131002070347_add_user_id_parent_type_index_on_views.rb
index 4c0d5535922..26401ad9c07 100644
--- a/db/migrate/20131002070347_add_user_id_parent_type_index_on_views.rb
+++ b/db/migrate/20131002070347_add_user_id_parent_type_index_on_views.rb
@@ -2,6 +2,6 @@
class AddUserIdParentTypeIndexOnViews < ActiveRecord::Migration[4.2]
def change
- add_index :views, [:user_id, :parent_type, :parent_id]
+ add_index :views, %i[user_id parent_type parent_id]
end
end
diff --git a/db/migrate/20131003061137_move_columns_to_user_stats.rb b/db/migrate/20131003061137_move_columns_to_user_stats.rb
index 2faa1324269..202c4d2fb15 100644
--- a/db/migrate/20131003061137_move_columns_to_user_stats.rb
+++ b/db/migrate/20131003061137_move_columns_to_user_stats.rb
@@ -10,7 +10,7 @@ class MoveColumnsToUserStats < ActiveRecord::Migration[4.2]
add_column :user_stats, :likes_received, :integer, default: 0, null: false
add_column :user_stats, :topic_reply_count, :integer, default: 0, null: false
- execute 'UPDATE user_stats s
+ execute "UPDATE user_stats s
SET topics_entered = u.topics_entered,
time_read = u.time_read,
days_visited = u.days_visited,
@@ -19,7 +19,7 @@ class MoveColumnsToUserStats < ActiveRecord::Migration[4.2]
likes_received = u.likes_received,
topic_reply_count = u.topic_reply_count
FROM users u WHERE u.id = s.user_id
- '
+ "
remove_column :users, :topics_entered
remove_column :users, :time_read
@@ -39,7 +39,7 @@ class MoveColumnsToUserStats < ActiveRecord::Migration[4.2]
add_column :users, :likes_received, :integer
add_column :users, :topic_reply_count, :integer
- execute 'UPDATE users s
+ execute "UPDATE users s
SET topics_entered = u.topics_entered,
time_read = u.time_read,
days_visited = u.days_visited,
@@ -48,7 +48,7 @@ class MoveColumnsToUserStats < ActiveRecord::Migration[4.2]
likes_received = u.likes_received,
topic_reply_count = u.topic_reply_count
FROM user_stats u WHERE s.id = u.user_id
- '
+ "
remove_column :user_stats, :topics_entered
remove_column :user_stats, :time_read
diff --git a/db/migrate/20131014203951_backfill_post_upload_reverse_index.rb b/db/migrate/20131014203951_backfill_post_upload_reverse_index.rb
index 0c5f4bb3e67..1d3b1d47027 100644
--- a/db/migrate/20131014203951_backfill_post_upload_reverse_index.rb
+++ b/db/migrate/20131014203951_backfill_post_upload_reverse_index.rb
@@ -1,19 +1,20 @@
# frozen_string_literal: true
class BackfillPostUploadReverseIndex < ActiveRecord::Migration[4.2]
-
def up
# clean the reverse index
execute "TRUNCATE TABLE post_uploads"
# fill the reverse index up
- Post.select([:id, :cooked]).find_each do |post|
- doc = Nokogiri::HTML5::fragment(post.cooked)
- # images
- doc.search("img").each { |img| add_to_reverse_index(img['src'], post.id) }
- # thumbnails and/or attachments
- doc.search("a").each { |a| add_to_reverse_index(a['href'], post.id) }
- end
+ Post
+ .select(%i[id cooked])
+ .find_each do |post|
+ doc = Nokogiri::HTML5.fragment(post.cooked)
+ # images
+ doc.search("img").each { |img| add_to_reverse_index(img["src"], post.id) }
+ # thumbnails and/or attachments
+ doc.search("a").each { |a| add_to_reverse_index(a["href"], post.id) }
+ end
end
def add_to_reverse_index(url, post_id)
@@ -72,5 +73,4 @@ class BackfillPostUploadReverseIndex < ActiveRecord::Migration[4.2]
def is_s3_avatar?(url)
url.starts_with?(s3_avatar_base_url)
end
-
end
diff --git a/db/migrate/20131015131652_create_post_details.rb b/db/migrate/20131015131652_create_post_details.rb
index 4371c0efb7a..e17c30d491a 100644
--- a/db/migrate/20131015131652_create_post_details.rb
+++ b/db/migrate/20131015131652_create_post_details.rb
@@ -4,13 +4,13 @@ class CreatePostDetails < ActiveRecord::Migration[4.2]
def change
create_table :post_details do |t|
t.belongs_to :post
- t.string :key
- t.string :value, size: 512
- t.text :extra
+ t.string :key
+ t.string :value, size: 512
+ t.text :extra
t.timestamps null: false
end
- add_index :post_details, [:post_id, :key], unique: true
+ add_index :post_details, %i[post_id key], unique: true
end
end
diff --git a/db/migrate/20131022045114_add_uncategorized_category.rb b/db/migrate/20131022045114_add_uncategorized_category.rb
index cb362fb0c3d..170ccf264e4 100644
--- a/db/migrate/20131022045114_add_uncategorized_category.rb
+++ b/db/migrate/20131022045114_add_uncategorized_category.rb
@@ -2,14 +2,12 @@
class AddUncategorizedCategory < ActiveRecord::Migration[4.2]
def up
-
result = execute "SELECT 1 FROM categories WHERE lower(name) = 'uncategorized'"
- name = +'Uncategorized'
- if result.count > 0
- name << SecureRandom.hex
- end
+ name = +"Uncategorized"
+ name << SecureRandom.hex if result.count > 0
- result = execute "INSERT INTO categories
+ result =
+ execute "INSERT INTO categories
(name,color,slug,description,text_color, user_id, created_at, updated_at, position)
VALUES ('#{name}', '0088CC', 'uncategorized', '', 'FFFFFF', -1, now(), now(), 0 )
RETURNING id
@@ -24,7 +22,6 @@ class AddUncategorizedCategory < ActiveRecord::Migration[4.2]
execute "UPDATE topics SET category_id = #{category_id} WHERE archetype = 'regular' AND category_id IS NULL"
execute "ALTER table topics ADD CONSTRAINT has_category_id CHECK (category_id IS NOT NULL OR archetype <> 'regular')"
-
end
def down
diff --git a/db/migrate/20131022151218_create_api_keys.rb b/db/migrate/20131022151218_create_api_keys.rb
index 1eed1250eae..78f0d934e00 100644
--- a/db/migrate/20131022151218_create_api_keys.rb
+++ b/db/migrate/20131022151218_create_api_keys.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
class CreateApiKeys < ActiveRecord::Migration[4.2]
-
def up
create_table :api_keys do |t|
t.string :key, limit: 64, null: false
@@ -20,5 +19,4 @@ class CreateApiKeys < ActiveRecord::Migration[4.2]
def down
raise ActiveRecord::IrreversibleMigration.new
end
-
end
diff --git a/db/migrate/20131107154900_rename_banned_to_suspended.rb b/db/migrate/20131107154900_rename_banned_to_suspended.rb
index 09d0a9f7e48..374de38fa40 100644
--- a/db/migrate/20131107154900_rename_banned_to_suspended.rb
+++ b/db/migrate/20131107154900_rename_banned_to_suspended.rb
@@ -2,7 +2,7 @@
class RenameBannedToSuspended < ActiveRecord::Migration[4.2]
def change
- rename_column :users, :banned_at, :suspended_at
+ rename_column :users, :banned_at, :suspended_at
rename_column :users, :banned_till, :suspended_till
end
end
diff --git a/db/migrate/20131114185225_add_participant_count_to_topics.rb b/db/migrate/20131114185225_add_participant_count_to_topics.rb
index 214d83d6283..84a4e0b1f41 100644
--- a/db/migrate/20131114185225_add_participant_count_to_topics.rb
+++ b/db/migrate/20131114185225_add_participant_count_to_topics.rb
@@ -11,5 +11,4 @@ class AddParticipantCountToTopics < ActiveRecord::Migration[4.2]
def down
remove_column :topics, :participant_count
end
-
end
diff --git a/db/migrate/20131120055018_move_emoji_to_new_location.rb b/db/migrate/20131120055018_move_emoji_to_new_location.rb
index b564a7326df..1d62f47eba2 100644
--- a/db/migrate/20131120055018_move_emoji_to_new_location.rb
+++ b/db/migrate/20131120055018_move_emoji_to_new_location.rb
@@ -2,10 +2,14 @@
class MoveEmojiToNewLocation < ActiveRecord::Migration[4.2]
def up
- execute("update posts set cooked = regexp_replace(cooked, '\(<img[^\>]*)assets\/emoji\/', '\\1plugins\/emoji\/images\/' , 'g') where cooked like '%emoji%'")
+ execute(
+ "update posts set cooked = regexp_replace(cooked, '\(<img[^\>]*)assets\/emoji\/', '\\1plugins\/emoji\/images\/' , 'g') where cooked like '%emoji%'",
+ )
end
def down
- execute("update posts set cooked = regexp_replace(cooked, '\(<img[^\>]*)plugins\/emoji\/images\/', '\\1assets\/emoji\/' , 'g') where cooked like '%emoji%'")
+ execute(
+ "update posts set cooked = regexp_replace(cooked, '\(<img[^\>]*)plugins\/emoji\/images\/', '\\1assets\/emoji\/' , 'g') where cooked like '%emoji%'",
+ )
end
end
diff --git a/db/migrate/20131209091702_create_post_revisions.rb b/db/migrate/20131209091702_create_post_revisions.rb
index 9e97b05bf11..a9decbfe3dc 100644
--- a/db/migrate/20131209091702_create_post_revisions.rb
+++ b/db/migrate/20131209091702_create_post_revisions.rb
@@ -17,7 +17,7 @@ class CreatePostRevisions < ActiveRecord::Migration[4.2]
change_table :post_revisions do |t|
t.index :post_id
- t.index [:post_id, :number]
+ t.index %i[post_id number]
end
end
diff --git a/db/migrate/20131209091742_create_topic_revisions.rb b/db/migrate/20131209091742_create_topic_revisions.rb
index f4e53afc998..a48c568ffcd 100644
--- a/db/migrate/20131209091742_create_topic_revisions.rb
+++ b/db/migrate/20131209091742_create_topic_revisions.rb
@@ -17,7 +17,7 @@ class CreateTopicRevisions < ActiveRecord::Migration[4.2]
change_table :topic_revisions do |t|
t.index :topic_id
- t.index [:topic_id, :number]
+ t.index %i[topic_id number]
end
end
diff --git a/db/migrate/20131210181901_migrate_word_counts.rb b/db/migrate/20131210181901_migrate_word_counts.rb
index aa998891633..861547925c5 100644
--- a/db/migrate/20131210181901_migrate_word_counts.rb
+++ b/db/migrate/20131210181901_migrate_word_counts.rb
@@ -4,32 +4,34 @@ class MigrateWordCounts < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
def up
- post_ids = execute("SELECT id FROM posts WHERE word_count IS NULL LIMIT 500").map { |r| r['id'].to_i }
+ post_ids =
+ execute("SELECT id FROM posts WHERE word_count IS NULL LIMIT 500").map { |r| r["id"].to_i }
while post_ids.length > 0
3.times do
begin
- execute "UPDATE posts SET word_count = COALESCE(array_length(regexp_split_to_array(raw, ' '),1), 0) WHERE id IN (#{post_ids.join(',')})"
+ execute "UPDATE posts SET word_count = COALESCE(array_length(regexp_split_to_array(raw, ' '),1), 0) WHERE id IN (#{post_ids.join(",")})"
break
rescue PG::Error
# Deadlock. Try again, up to 3 times.
end
end
- post_ids = execute("SELECT id FROM posts WHERE word_count IS NULL LIMIT 500").map { |r| r['id'].to_i }
+ post_ids =
+ execute("SELECT id FROM posts WHERE word_count IS NULL LIMIT 500").map { |r| r["id"].to_i }
end
- topic_ids = execute("SELECT id FROM topics WHERE word_count IS NULL LIMIT 500").map { |r| r['id'].to_i }
+ topic_ids =
+ execute("SELECT id FROM topics WHERE word_count IS NULL LIMIT 500").map { |r| r["id"].to_i }
while topic_ids.length > 0
3.times do
begin
- execute "UPDATE topics SET word_count = COALESCE((SELECT SUM(COALESCE(posts.word_count, 0)) FROM posts WHERE posts.topic_id = topics.id), 0) WHERE topics.id IN (#{topic_ids.join(',')})"
+ execute "UPDATE topics SET word_count = COALESCE((SELECT SUM(COALESCE(posts.word_count, 0)) FROM posts WHERE posts.topic_id = topics.id), 0) WHERE topics.id IN (#{topic_ids.join(",")})"
break
rescue PG::Error
# Deadlock. Try again, up to 3 times.
end
end
- topic_ids = execute("SELECT id FROM topics WHERE word_count IS NULL LIMIT 500").map { |r| r['id'].to_i }
+ topic_ids =
+ execute("SELECT id FROM topics WHERE word_count IS NULL LIMIT 500").map { |r| r["id"].to_i }
end
-
end
-
end
diff --git a/db/migrate/20131210234530_rename_version_column.rb b/db/migrate/20131210234530_rename_version_column.rb
index c524f13c8e6..4349f524ee9 100644
--- a/db/migrate/20131210234530_rename_version_column.rb
+++ b/db/migrate/20131210234530_rename_version_column.rb
@@ -1,11 +1,9 @@
# frozen_string_literal: true
class RenameVersionColumn < ActiveRecord::Migration[4.2]
-
def change
add_column :posts, :version, :integer, default: 1, null: false
execute "UPDATE posts SET version = cached_version"
remove_column :posts, :cached_version
end
-
end
diff --git a/db/migrate/20131223171005_create_top_topics.rb b/db/migrate/20131223171005_create_top_topics.rb
index 298f618b97c..ec1b05882ad 100644
--- a/db/migrate/20131223171005_create_top_topics.rb
+++ b/db/migrate/20131223171005_create_top_topics.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
class CreateTopTopics < ActiveRecord::Migration[4.2]
- PERIODS = [:yearly, :monthly, :weekly, :daily]
- SORT_ORDERS = [:posts, :views, :likes]
+ PERIODS = %i[yearly monthly weekly daily]
+ SORT_ORDERS = %i[posts views likes]
def change
create_table :top_topics, force: true do |t|
@@ -13,16 +13,14 @@ class CreateTopTopics < ActiveRecord::Migration[4.2]
t.integer "#{period}_#{sort}_count".to_sym, null: false, default: 0
end
end
-
end
add_index :top_topics, :topic_id, unique: true
PERIODS.each do |period|
SORT_ORDERS.each do |sort|
- add_index :top_topics, "#{period}_#{sort}_count".to_sym, order: 'desc'
+ add_index :top_topics, "#{period}_#{sort}_count".to_sym, order: "desc"
end
end
-
end
end
diff --git a/db/migrate/20131227164338_add_scores_to_top_topics.rb b/db/migrate/20131227164338_add_scores_to_top_topics.rb
index 040adc1127c..addeb688a2d 100644
--- a/db/migrate/20131227164338_add_scores_to_top_topics.rb
+++ b/db/migrate/20131227164338_add_scores_to_top_topics.rb
@@ -2,7 +2,7 @@
class AddScoresToTopTopics < ActiveRecord::Migration[4.2]
def change
- [:daily, :weekly, :monthly, :yearly].each do |period|
+ %i[daily weekly monthly yearly].each do |period|
add_column :top_topics, "#{period}_score".to_sym, :float
end
end
diff --git a/db/migrate/20140206195001_add_defaults_to_category_posts_and_topics_fields.rb b/db/migrate/20140206195001_add_defaults_to_category_posts_and_topics_fields.rb
index c676407c074..c4b506b6942 100644
--- a/db/migrate/20140206195001_add_defaults_to_category_posts_and_topics_fields.rb
+++ b/db/migrate/20140206195001_add_defaults_to_category_posts_and_topics_fields.rb
@@ -2,12 +2,12 @@
class AddDefaultsToCategoryPostsAndTopicsFields < ActiveRecord::Migration[4.2]
def change
- change_column_default :categories, :posts_week, 0
- change_column_default :categories, :posts_month, 0
- change_column_default :categories, :posts_year, 0
+ change_column_default :categories, :posts_week, 0
+ change_column_default :categories, :posts_month, 0
+ change_column_default :categories, :posts_year, 0
- change_column_default :categories, :topics_week, 0
+ change_column_default :categories, :topics_week, 0
change_column_default :categories, :topics_month, 0
- change_column_default :categories, :topics_year, 0
+ change_column_default :categories, :topics_year, 0
end
end
diff --git a/db/migrate/20140211230222_move_cas_settings.rb b/db/migrate/20140211230222_move_cas_settings.rb
index 1923408e484..07f038b58d9 100644
--- a/db/migrate/20140211230222_move_cas_settings.rb
+++ b/db/migrate/20140211230222_move_cas_settings.rb
@@ -6,9 +6,9 @@ class MoveCasSettings < ActiveRecord::Migration[4.2]
#convert the data over to be used by the plugin.
cas_hostname = SiteSetting.find_by(name: "cas_hostname")
cas_sso_hostname = SiteSetting.find_by(name: "cas_sso_hostname")
- if cas_hostname && ! cas_sso_hostname
+ if cas_hostname && !cas_sso_hostname
#convert the setting over for use by the plugin
- cas_hostname.update_attribute(:name, 'cas_sso_hostname')
+ cas_hostname.update_attribute(:name, "cas_sso_hostname")
elsif cas_hostname && cas_sso_hostname
#copy the setting over for use by the plugin and delete the original setting
cas_sso_hostname.update_attribute(:value, cas_hostname.value)
@@ -17,9 +17,9 @@ class MoveCasSettings < ActiveRecord::Migration[4.2]
cas_domainname = SiteSetting.find_by(name: "cas_domainname")
cas_sso_email_domain = SiteSetting.find_by(name: "cas_sso_email_domain")
- if cas_domainname && ! cas_sso_email_domain
+ if cas_domainname && !cas_sso_email_domain
#convert the setting over for use by the plugin
- cas_domainname.update_attribute(:name, 'cas_sso_email_domain')
+ cas_domainname.update_attribute(:name, "cas_sso_email_domain")
elsif cas_domainname && cas_sso_email_domain
#copy the setting over for use by the plugin and delete the original setting
cas_sso_email_domain.update_attribute(:value, cas_domainname.value)
@@ -27,12 +27,9 @@ class MoveCasSettings < ActiveRecord::Migration[4.2]
end
cas_logins = SiteSetting.find_by(name: "cas_logins")
- if cas_logins
- cas_logins.destroy
- end
-
- #remove the unused table
- drop_table :cas_user_infos
+ cas_logins.destroy if cas_logins
+ #remove the unused table
+ drop_table :cas_user_infos
end
end
diff --git a/db/migrate/20140214151255_add_skipped_to_email_logs.rb b/db/migrate/20140214151255_add_skipped_to_email_logs.rb
index 8af4e016b2b..19e111084d0 100644
--- a/db/migrate/20140214151255_add_skipped_to_email_logs.rb
+++ b/db/migrate/20140214151255_add_skipped_to_email_logs.rb
@@ -4,6 +4,6 @@ class AddSkippedToEmailLogs < ActiveRecord::Migration[4.2]
def change
add_column :email_logs, :skipped, :boolean, default: :false
add_column :email_logs, :skipped_reason, :string
- add_index :email_logs, [:skipped, :created_at]
+ add_index :email_logs, %i[skipped created_at]
end
end
diff --git a/db/migrate/20140220160510_rename_site_settings.rb b/db/migrate/20140220160510_rename_site_settings.rb
index 7424d1f4b25..05e05e8dcd0 100644
--- a/db/migrate/20140220160510_rename_site_settings.rb
+++ b/db/migrate/20140220160510_rename_site_settings.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
class RenameSiteSettings < ActiveRecord::Migration[4.2]
-
def up
execute "UPDATE site_settings SET name = 'allow_restore' WHERE name = 'allow_import'"
execute "UPDATE site_settings SET name = 'topics_per_period_in_top_summary' WHERE name = 'topics_per_period_in_summary'"
@@ -11,5 +10,4 @@ class RenameSiteSettings < ActiveRecord::Migration[4.2]
execute "UPDATE site_settings SET name = 'allow_import' WHERE name = 'allow_restore'"
execute "UPDATE site_settings SET name = 'topics_per_period_in_summary' WHERE name = 'topics_per_period_in_top_summary'"
end
-
end
diff --git a/db/migrate/20140305100909_create_user_badges.rb b/db/migrate/20140305100909_create_user_badges.rb
index 5ccca851e86..84d0f83a98d 100644
--- a/db/migrate/20140305100909_create_user_badges.rb
+++ b/db/migrate/20140305100909_create_user_badges.rb
@@ -9,6 +9,6 @@ class CreateUserBadges < ActiveRecord::Migration[4.2]
t.integer :granted_by_id, null: false
end
- add_index :user_badges, [:badge_id, :user_id], unique: true
+ add_index :user_badges, %i[badge_id user_id], unique: true
end
end
diff --git a/db/migrate/20140306223522_move_topic_revisions_to_post_revisions.rb b/db/migrate/20140306223522_move_topic_revisions_to_post_revisions.rb
index 0d7dbaa522a..68a437e4450 100644
--- a/db/migrate/20140306223522_move_topic_revisions_to_post_revisions.rb
+++ b/db/migrate/20140306223522_move_topic_revisions_to_post_revisions.rb
@@ -12,7 +12,7 @@ class MoveTopicRevisionsToPostRevisions < ActiveRecord::Migration[4.2]
SQL
- execute <<SQL
+ execute <<SQL
UPDATE post_revisions r SET number = 2 + (
SELECT COUNT(*) FROM post_revisions r2
@@ -35,7 +35,6 @@ SQL
DROP TABLE topic_revisions
SQL
-
end
def down
diff --git a/db/migrate/20140318150412_add_excerpt_to_topics.rb b/db/migrate/20140318150412_add_excerpt_to_topics.rb
index 0ef4bdb598f..081764a6b2a 100644
--- a/db/migrate/20140318150412_add_excerpt_to_topics.rb
+++ b/db/migrate/20140318150412_add_excerpt_to_topics.rb
@@ -4,9 +4,17 @@ class AddExcerptToTopics < ActiveRecord::Migration[4.2]
def up
add_column :topics, :excerpt, :string, limit: 1000
- topic_ids = execute("SELECT id FROM topics WHERE pinned_at IS NOT NULL").map { |r| r['id'].to_i }
+ topic_ids =
+ execute("SELECT id FROM topics WHERE pinned_at IS NOT NULL").map { |r| r["id"].to_i }
topic_ids.each do |topic_id|
- cooked = execute("SELECT cooked FROM posts WHERE topic_id = #{topic_id} ORDER BY post_number ASC LIMIT 1")[0]['cooked']
+ cooked =
+ execute(
+ "SELECT cooked FROM posts WHERE topic_id = #{topic_id} ORDER BY post_number ASC LIMIT 1",
+ )[
+ 0
+ ][
+ "cooked"
+ ]
if cooked
excerpt = ExcerptParser.get_excerpt(cooked, 220, strip_links: true)
execute "UPDATE topics SET excerpt = #{ActiveRecord::Base.sanitize(excerpt)} WHERE id = #{topic_id}"
diff --git a/db/migrate/20140318203559_add_created_at_index_to_posts.rb b/db/migrate/20140318203559_add_created_at_index_to_posts.rb
index ff8d07136da..a09ab2237b0 100644
--- a/db/migrate/20140318203559_add_created_at_index_to_posts.rb
+++ b/db/migrate/20140318203559_add_created_at_index_to_posts.rb
@@ -4,14 +4,16 @@ class AddCreatedAtIndexToPosts < ActiveRecord::Migration[4.2]
def up
execute "CREATE INDEX idx_posts_created_at_topic_id ON posts(created_at, topic_id) WHERE deleted_at IS NULL"
add_column :categories, :topics_day, :integer, default: 0
- add_column :categories, :posts_day, :integer, default: 0
+ add_column :categories, :posts_day, :integer, default: 0
execute "DROP INDEX index_topics_on_deleted_at_and_visible_and_archetype_and_id"
- add_index :topics, [:deleted_at, :visible, :archetype, :category_id, :id], name: "idx_topics_front_page"
+ add_index :topics,
+ %i[deleted_at visible archetype category_id id],
+ name: "idx_topics_front_page"
end
def down
execute "DROP INDEX idx_topics_front_page"
- add_index :topics, [:deleted_at, :visible, :archetype, :id]
+ add_index :topics, %i[deleted_at visible archetype id]
remove_column :categories, :posts_day
remove_column :categories, :topics_day
execute "DROP INDEX idx_posts_created_at_topic_id"
diff --git a/db/migrate/20140408152401_add_default_value_to_top_topic_scores.rb b/db/migrate/20140408152401_add_default_value_to_top_topic_scores.rb
index a4abb725b06..33dd9d7da5a 100644
--- a/db/migrate/20140408152401_add_default_value_to_top_topic_scores.rb
+++ b/db/migrate/20140408152401_add_default_value_to_top_topic_scores.rb
@@ -2,7 +2,7 @@
class AddDefaultValueToTopTopicScores < ActiveRecord::Migration[4.2]
def change
- [:daily, :weekly, :monthly, :yearly].each do |period|
+ %i[daily weekly monthly yearly].each do |period|
change_column_default :top_topics, "#{period}_score".to_sym, 0
end
end
diff --git a/db/migrate/20140416202746_create_color_schemes.rb b/db/migrate/20140416202746_create_color_schemes.rb
index dd1137590f7..c62aea0712d 100644
--- a/db/migrate/20140416202746_create_color_schemes.rb
+++ b/db/migrate/20140416202746_create_color_schemes.rb
@@ -3,11 +3,11 @@
class CreateColorSchemes < ActiveRecord::Migration[4.2]
def change
create_table :color_schemes do |t|
- t.string :name, null: false
- t.boolean :enabled, null: false, default: false
+ t.string :name, null: false
+ t.boolean :enabled, null: false, default: false
t.integer :versioned_id
- t.integer :version, null: false, default: 1
+ t.integer :version, null: false, default: 1
t.timestamps null: false
end
diff --git a/db/migrate/20140416202801_create_color_scheme_colors.rb b/db/migrate/20140416202801_create_color_scheme_colors.rb
index 37f3009ebf1..c13befa8511 100644
--- a/db/migrate/20140416202801_create_color_scheme_colors.rb
+++ b/db/migrate/20140416202801_create_color_scheme_colors.rb
@@ -3,9 +3,9 @@
class CreateColorSchemeColors < ActiveRecord::Migration[4.2]
def change
create_table :color_scheme_colors do |t|
- t.string :name, null: false
- t.string :hex, null: false
- t.integer :opacity, null: false, default: 100
+ t.string :name, null: false
+ t.string :hex, null: false
+ t.integer :opacity, null: false, default: 100
t.integer :color_scheme_id, null: false
t.timestamps null: false
diff --git a/db/migrate/20140421235646_add_user_custom_fields.rb b/db/migrate/20140421235646_add_user_custom_fields.rb
index bb61fb69d44..62af7b69537 100644
--- a/db/migrate/20140421235646_add_user_custom_fields.rb
+++ b/db/migrate/20140421235646_add_user_custom_fields.rb
@@ -9,6 +9,6 @@ class AddUserCustomFields < ActiveRecord::Migration[4.2]
t.timestamps null: false
end
- add_index :user_custom_fields, [:user_id, :name]
+ add_index :user_custom_fields, %i[user_id name]
end
end
diff --git a/db/migrate/20140425125742_add_custom_fields.rb b/db/migrate/20140425125742_add_custom_fields.rb
index 4c7515c06f0..95551db74db 100644
--- a/db/migrate/20140425125742_add_custom_fields.rb
+++ b/db/migrate/20140425125742_add_custom_fields.rb
@@ -23,8 +23,8 @@ class AddCustomFields < ActiveRecord::Migration[4.2]
t.timestamps null: false
end
- add_index :category_custom_fields, [:category_id, :name]
- add_index :group_custom_fields, [:group_id, :name]
- add_index :post_custom_fields, [:post_id, :name]
+ add_index :category_custom_fields, %i[category_id name]
+ add_index :group_custom_fields, %i[group_id name]
+ add_index :post_custom_fields, %i[post_id name]
end
end
diff --git a/db/migrate/20140425135354_add_topic_custom_fields.rb b/db/migrate/20140425135354_add_topic_custom_fields.rb
index 7423f747370..796cfc7f47f 100644
--- a/db/migrate/20140425135354_add_topic_custom_fields.rb
+++ b/db/migrate/20140425135354_add_topic_custom_fields.rb
@@ -9,7 +9,7 @@ class AddTopicCustomFields < ActiveRecord::Migration[4.2]
t.timestamps null: false
end
- add_index :topic_custom_fields, [:topic_id, :name]
+ add_index :topic_custom_fields, %i[topic_id name]
# migrate meta_data into custom fields
execute <<-SQL
diff --git a/db/migrate/20140504174212_increment_reserved_trust_level_badge_ids.rb b/db/migrate/20140504174212_increment_reserved_trust_level_badge_ids.rb
index 86486892eb4..3f3e52fc58f 100644
--- a/db/migrate/20140504174212_increment_reserved_trust_level_badge_ids.rb
+++ b/db/migrate/20140504174212_increment_reserved_trust_level_badge_ids.rb
@@ -4,12 +4,14 @@ class IncrementReservedTrustLevelBadgeIds < ActiveRecord::Migration[4.2]
def up
execute "ALTER SEQUENCE badges_id_seq START WITH 100"
- max_badge_id = Badge.order('id DESC').limit(1).first.try(:id)
- Badge.where('id > 0 AND id <= 100').find_each do |badge|
- new_id = badge.id + max_badge_id + 100
- UserBadge.where(badge_id: badge.id).update_all badge_id: new_id
- badge.update_column :id, new_id
- end
+ max_badge_id = Badge.order("id DESC").limit(1).first.try(:id)
+ Badge
+ .where("id > 0 AND id <= 100")
+ .find_each do |badge|
+ new_id = badge.id + max_badge_id + 100
+ UserBadge.where(badge_id: badge.id).update_all badge_id: new_id
+ badge.update_column :id, new_id
+ end
end
def down
diff --git a/db/migrate/20140520062826_add_multiple_award_to_badges.rb b/db/migrate/20140520062826_add_multiple_award_to_badges.rb
index 483bf62e3c8..29e3ac1aa3a 100644
--- a/db/migrate/20140520062826_add_multiple_award_to_badges.rb
+++ b/db/migrate/20140520062826_add_multiple_award_to_badges.rb
@@ -6,13 +6,13 @@ class AddMultipleAwardToBadges < ActiveRecord::Migration[4.2]
reversible do |dir|
dir.up do
- remove_index :user_badges, column: [:badge_id, :user_id]
- add_index :user_badges, [:badge_id, :user_id]
+ remove_index :user_badges, column: %i[badge_id user_id]
+ add_index :user_badges, %i[badge_id user_id]
end
dir.down do
- remove_index :user_badges, column: [:badge_id, :user_id]
- add_index :user_badges, [:badge_id, :user_id], unique: true
+ remove_index :user_badges, column: %i[badge_id user_id]
+ add_index :user_badges, %i[badge_id user_id], unique: true
end
end
end
diff --git a/db/migrate/20140521220115_google_openid_default_has_changed.rb b/db/migrate/20140521220115_google_openid_default_has_changed.rb
index fc6993e2b4e..13bcb681a07 100644
--- a/db/migrate/20140521220115_google_openid_default_has_changed.rb
+++ b/db/migrate/20140521220115_google_openid_default_has_changed.rb
@@ -5,14 +5,18 @@ class GoogleOpenidDefaultHasChanged < ActiveRecord::Migration[4.2]
users_count_query = DB.query_single("SELECT count(*) FROM users")
if users_count_query.first.to_i > 1
# This is an existing site.
- result = DB.query_single("SELECT count(*) FROM site_settings WHERE name = 'enable_google_logins'")
+ result =
+ DB.query_single("SELECT count(*) FROM site_settings WHERE name = 'enable_google_logins'")
if result.first.to_i == 0
# The old default was true, so add a row to keep it that way.
execute "INSERT INTO site_settings (name, data_type, value, created_at, updated_at) VALUES ('enable_google_logins', 5, 't', now(), now())"
end
# Don't enable the new Google setting on an existing site.
- result = DB.query_single("SELECT count(*) FROM site_settings WHERE name = 'enable_google_oauth2_logins'")
+ result =
+ DB.query_single(
+ "SELECT count(*) FROM site_settings WHERE name = 'enable_google_oauth2_logins'",
+ )
if result.first.to_i == 0
execute "INSERT INTO site_settings (name, data_type, value, created_at, updated_at) VALUES ('enable_google_oauth2_logins', 5, 'f', now(), now())"
end
diff --git a/db/migrate/20140526185749_change_category_uniquness_contstraint.rb b/db/migrate/20140526185749_change_category_uniquness_contstraint.rb
index 27e5a0ac1d6..59b6e909e4b 100644
--- a/db/migrate/20140526185749_change_category_uniquness_contstraint.rb
+++ b/db/migrate/20140526185749_change_category_uniquness_contstraint.rb
@@ -2,7 +2,7 @@
class ChangeCategoryUniqunessContstraint < ActiveRecord::Migration[4.2]
def change
- remove_index :categories, name: 'index_categories_on_name'
- add_index :categories, [:parent_category_id, :name], unique: true
+ remove_index :categories, name: "index_categories_on_name"
+ add_index :categories, %i[parent_category_id name], unique: true
end
end
diff --git a/db/migrate/20140530002535_remove_system_avatars_from_user_avatars.rb b/db/migrate/20140530002535_remove_system_avatars_from_user_avatars.rb
index aaa17e901f9..f28f4bc43a8 100644
--- a/db/migrate/20140530002535_remove_system_avatars_from_user_avatars.rb
+++ b/db/migrate/20140530002535_remove_system_avatars_from_user_avatars.rb
@@ -11,7 +11,7 @@ class RemoveSystemAvatarsFromUserAvatars < ActiveRecord::Migration[4.2]
# normally we dont reach into the object model, but we have to here.
# otherwise we will wait a real long time for uploads to go away
skip = -1
- while skip = destroy_system_avatar_batch(skip) do
+ while skip = destroy_system_avatar_batch(skip)
puts "Destroyed up to id: #{skip}"
end
@@ -22,20 +22,21 @@ class RemoveSystemAvatarsFromUserAvatars < ActiveRecord::Migration[4.2]
def destroy_system_avatar_batch(skip)
initial = skip
- Upload.where('id IN (SELECT system_upload_id FROM user_avatars) AND id > ?', skip)
+ Upload
+ .where("id IN (SELECT system_upload_id FROM user_avatars) AND id > ?", skip)
.order(:id)
.limit(500)
.each do |upload|
- skip = upload.id
- begin
- upload.destroy
- rescue
- Rails.logger.warn "Could not destroy system avatar #{upload.id}"
+ skip = upload.id
+ begin
+ upload.destroy
+ rescue StandardError
+ Rails.logger.warn "Could not destroy system avatar #{upload.id}"
+ end
end
- end
skip == initial ? nil : skip
- rescue
+ rescue StandardError
Rails.logger.warn "Could not destroy system avatars, skipping"
nil
end
diff --git a/db/migrate/20140604145431_disable_external_auths_by_default.rb b/db/migrate/20140604145431_disable_external_auths_by_default.rb
index dd8363f265b..19ff7599f0d 100644
--- a/db/migrate/20140604145431_disable_external_auths_by_default.rb
+++ b/db/migrate/20140604145431_disable_external_auths_by_default.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
class DisableExternalAuthsByDefault < ActiveRecord::Migration[4.2]
-
def enable_setting_if_default(name)
result = DB.query_single("SELECT count(*) count FROM site_settings WHERE name = '#{name}'")
if result.first.to_i == 0
@@ -13,10 +12,10 @@ class DisableExternalAuthsByDefault < ActiveRecord::Migration[4.2]
users_count_query = DB.query_single("SELECT count(*) FROM users")
if users_count_query.first.to_i > 1
# existing site, so keep settings as they are
- enable_setting_if_default 'enable_yahoo_logins'
- enable_setting_if_default 'enable_google_oauth2_logins'
- enable_setting_if_default 'enable_twitter_logins'
- enable_setting_if_default 'enable_facebook_logins'
+ enable_setting_if_default "enable_yahoo_logins"
+ enable_setting_if_default "enable_google_oauth2_logins"
+ enable_setting_if_default "enable_twitter_logins"
+ enable_setting_if_default "enable_facebook_logins"
end
end
diff --git a/db/migrate/20140618001820_dont_auto_muto_topics.rb b/db/migrate/20140618001820_dont_auto_muto_topics.rb
index ded7399691a..0dafdd14d1a 100644
--- a/db/migrate/20140618001820_dont_auto_muto_topics.rb
+++ b/db/migrate/20140618001820_dont_auto_muto_topics.rb
@@ -3,10 +3,10 @@
class DontAutoMutoTopics < ActiveRecord::Migration[4.2]
def change
# muting all new topics was a mistake, revert it
- execute 'DELETE FROM topic_users WHERE notification_level = 0 and notifications_reason_id =7 AND first_visited_at IS NULL'
+ execute "DELETE FROM topic_users WHERE notification_level = 0 and notifications_reason_id =7 AND first_visited_at IS NULL"
- execute 'UPDATE topic_users SET notification_level = 1,
+ execute "UPDATE topic_users SET notification_level = 1,
notifications_reason_id = NULL
- WHERE notification_level = 0 AND notifications_reason_id =7'
+ WHERE notification_level = 0 AND notifications_reason_id =7"
end
end
diff --git a/db/migrate/20140623195618_fix_categories_constraint.rb b/db/migrate/20140623195618_fix_categories_constraint.rb
index 5591e14b116..91fcff7c4b2 100644
--- a/db/migrate/20140623195618_fix_categories_constraint.rb
+++ b/db/migrate/20140623195618_fix_categories_constraint.rb
@@ -2,7 +2,7 @@
class FixCategoriesConstraint < ActiveRecord::Migration[4.2]
def change
- remove_index :categories, name: 'index_categories_on_parent_category_id_and_name'
+ remove_index :categories, name: "index_categories_on_parent_category_id_and_name"
# Remove any previous duplicates
execute "DELETE FROM categories WHERE id IN (SELECT id FROM (SELECT id, row_number() over (partition BY parent_category_id, name ORDER BY id) AS rnum FROM categories) t WHERE t.rnum > 1)"
diff --git a/db/migrate/20140705081453_index_user_badges.rb b/db/migrate/20140705081453_index_user_badges.rb
index 1f7d28bfaa4..79cc45a4c87 100644
--- a/db/migrate/20140705081453_index_user_badges.rb
+++ b/db/migrate/20140705081453_index_user_badges.rb
@@ -2,12 +2,12 @@
class IndexUserBadges < ActiveRecord::Migration[4.2]
def change
- execute 'DELETE FROM user_badges USING user_badges ub2
+ execute "DELETE FROM user_badges USING user_badges ub2
WHERE user_badges.badge_id = ub2.badge_id AND
user_badges.user_id = ub2.user_id AND
user_badges.post_id IS NOT NULL AND
user_badges.id < ub2.id
- '
- add_index :user_badges, [:badge_id, :user_id, :post_id], unique: true, where: 'post_id IS NOT NULL'
+ "
+ add_index :user_badges, %i[badge_id user_id post_id], unique: true, where: "post_id IS NOT NULL"
end
end
diff --git a/db/migrate/20140711193923_remove_email_in_address_setting.rb b/db/migrate/20140711193923_remove_email_in_address_setting.rb
index 22d5dbbe75a..b1f64f92a28 100644
--- a/db/migrate/20140711193923_remove_email_in_address_setting.rb
+++ b/db/migrate/20140711193923_remove_email_in_address_setting.rb
@@ -2,9 +2,14 @@
class RemoveEmailInAddressSetting < ActiveRecord::Migration[4.2]
def up
- uncat_id = DB.query_single("SELECT value FROM site_settings WHERE name = 'uncategorized_category_id'").first
- cat_id_r = DB.query_single("SELECT value FROM site_settings WHERE name = 'email_in_category'").first
- email_r = DB.query_single("SELECT value FROM site_settings WHERE name = 'email_in_address'").first
+ uncat_id =
+ DB.query_single(
+ "SELECT value FROM site_settings WHERE name = 'uncategorized_category_id'",
+ ).first
+ cat_id_r =
+ DB.query_single("SELECT value FROM site_settings WHERE name = 'email_in_category'").first
+ email_r =
+ DB.query_single("SELECT value FROM site_settings WHERE name = 'email_in_address'").first
if email_r
category_id = uncat_id["value"].to_i
category_id = cat_id_r["value"].to_i if cat_id_r
@@ -12,7 +17,9 @@ class RemoveEmailInAddressSetting < ActiveRecord::Migration[4.2]
DB.exec("UPDATE categories SET email_in = ? WHERE id = ?", email, category_id)
end
- DB.exec("DELETE FROM site_settings WHERE name = 'email_in_category' OR name = 'email_in_address'")
+ DB.exec(
+ "DELETE FROM site_settings WHERE name = 'email_in_category' OR name = 'email_in_address'",
+ )
end
def down
diff --git a/db/migrate/20140715013018_correct_post_number_index.rb b/db/migrate/20140715013018_correct_post_number_index.rb
index 9d0e0f80fb4..01d74b1c7af 100644
--- a/db/migrate/20140715013018_correct_post_number_index.rb
+++ b/db/migrate/20140715013018_correct_post_number_index.rb
@@ -2,7 +2,6 @@
class CorrectPostNumberIndex < ActiveRecord::Migration[4.2]
def change
-
begin
a = execute <<SQL
UPDATE posts SET post_number = post_number + 1
@@ -22,7 +21,7 @@ class CorrectPostNumberIndex < ActiveRecord::Migration[4.2]
SQL
end until a.cmdtuples == 0
- remove_index :posts, [:topic_id, :post_number]
- add_index :posts, [:topic_id, :post_number], unique: true
+ remove_index :posts, %i[topic_id post_number]
+ add_index :posts, %i[topic_id post_number], unique: true
end
end
diff --git a/db/migrate/20140715055242_add_quoted_posts.rb b/db/migrate/20140715055242_add_quoted_posts.rb
index d3052b8a07c..de433f09125 100644
--- a/db/migrate/20140715055242_add_quoted_posts.rb
+++ b/db/migrate/20140715055242_add_quoted_posts.rb
@@ -8,16 +8,16 @@ class AddQuotedPosts < ActiveRecord::Migration[4.2]
t.timestamps null: false
end
- add_index :quoted_posts, [:post_id, :quoted_post_id], unique: true
- add_index :quoted_posts, [:quoted_post_id, :post_id], unique: true
+ add_index :quoted_posts, %i[post_id quoted_post_id], unique: true
+ add_index :quoted_posts, %i[quoted_post_id post_id], unique: true
# NOTE this can be done in pg but too much of a headache
id = 0
- while id = backfill_batch(id, 1000); end
+ while id = backfill_batch(id, 1000)
+ end
end
def backfill_batch(start_id, batch_size)
-
results = execute <<SQL
SELECT id, cooked
FROM posts
@@ -34,19 +34,21 @@ SQL
uniq = {}
- doc.css("aside.quote[data-topic]").each do |a|
- topic_id = a['data-topic'].to_i
- post_number = a['data-post'].to_i
+ doc
+ .css("aside.quote[data-topic]")
+ .each do |a|
+ topic_id = a["data-topic"].to_i
+ post_number = a["data-post"].to_i
- next if uniq[[topic_id, post_number]]
- uniq[[topic_id, post_number]] = true
+ next if uniq[[topic_id, post_number]]
+ uniq[[topic_id, post_number]] = true
- execute "INSERT INTO quoted_posts(post_id, quoted_post_id, created_at, updated_at)
+ execute "INSERT INTO quoted_posts(post_id, quoted_post_id, created_at, updated_at)
SELECT #{post_id}, id, created_at, updated_at
FROM posts
WHERE post_number = #{post_number} AND
topic_id = #{topic_id}"
- end
+ end
end
max_id
diff --git a/db/migrate/20140715160720_update_users_case_insensitive_emails.rb b/db/migrate/20140715160720_update_users_case_insensitive_emails.rb
index b9c02025807..5f108dfc747 100644
--- a/db/migrate/20140715160720_update_users_case_insensitive_emails.rb
+++ b/db/migrate/20140715160720_update_users_case_insensitive_emails.rb
@@ -14,7 +14,7 @@ class UpdateUsersCaseInsensitiveEmails < ActiveRecord::Migration[4.2]
SQL
results.each do |row|
- execute "UPDATE users SET email = '#{row['email'].downcase}#{row['count']}' WHERE id = #{row['id']}"
+ execute "UPDATE users SET email = '#{row["email"].downcase}#{row["count"]}' WHERE id = #{row["id"]}"
end
execute "UPDATE users SET email = lower(email)"
diff --git a/db/migrate/20140715190552_remove_uncategorized_parents.rb b/db/migrate/20140715190552_remove_uncategorized_parents.rb
index 41a8243e728..6dc3da97507 100644
--- a/db/migrate/20140715190552_remove_uncategorized_parents.rb
+++ b/db/migrate/20140715190552_remove_uncategorized_parents.rb
@@ -3,8 +3,8 @@
class RemoveUncategorizedParents < ActiveRecord::Migration[4.2]
def up
uncat = execute("SELECT value FROM site_settings WHERE name = 'uncategorized_category_id'")
- if uncat && uncat[0] && uncat[0]['value']
- execute "UPDATE categories SET parent_category_id = NULL where id = #{uncat[0]['value'].to_i}"
+ if uncat && uncat[0] && uncat[0]["value"]
+ execute "UPDATE categories SET parent_category_id = NULL where id = #{uncat[0]["value"].to_i}"
end
end
diff --git a/db/migrate/20140716063802_add_badge_groupings.rb b/db/migrate/20140716063802_add_badge_groupings.rb
index 700a6b61e2d..117a0454259 100644
--- a/db/migrate/20140716063802_add_badge_groupings.rb
+++ b/db/migrate/20140716063802_add_badge_groupings.rb
@@ -10,6 +10,5 @@ class AddBadgeGroupings < ActiveRecord::Migration[4.2]
end
add_column :badges, :badge_grouping_id, :integer
-
end
end
diff --git a/db/migrate/20140718041445_set_default_badge_grouping.rb b/db/migrate/20140718041445_set_default_badge_grouping.rb
index e44d7c4d729..cdc2a98d315 100644
--- a/db/migrate/20140718041445_set_default_badge_grouping.rb
+++ b/db/migrate/20140718041445_set_default_badge_grouping.rb
@@ -2,7 +2,7 @@
class SetDefaultBadgeGrouping < ActiveRecord::Migration[4.2]
def change
- execute 'UPDATE badges SET badge_grouping_id = 5 WHERE badge_grouping_id IS NULL'
+ execute "UPDATE badges SET badge_grouping_id = 5 WHERE badge_grouping_id IS NULL"
change_column :badges, :badge_grouping_id, :integer, null: false, default: 5
end
end
diff --git a/db/migrate/20140728120708_fix_index_on_post_action.rb b/db/migrate/20140728120708_fix_index_on_post_action.rb
index 0efc4c8f356..4cfed6bb9b8 100644
--- a/db/migrate/20140728120708_fix_index_on_post_action.rb
+++ b/db/migrate/20140728120708_fix_index_on_post_action.rb
@@ -3,6 +3,9 @@
class FixIndexOnPostAction < ActiveRecord::Migration[4.2]
def change
remove_index "post_actions", name: "idx_unique_actions"
- add_index "post_actions", ["user_id", "post_action_type_id", "post_id", "deleted_at", "targets_topic"], name: "idx_unique_actions", unique: true
+ add_index "post_actions",
+ %w[user_id post_action_type_id post_id deleted_at targets_topic],
+ name: "idx_unique_actions",
+ unique: true
end
end
diff --git a/db/migrate/20140729092525_remove_unique_constraint_from_invites_index.rb b/db/migrate/20140729092525_remove_unique_constraint_from_invites_index.rb
index 9e0fb75f234..7b5df3de11e 100644
--- a/db/migrate/20140729092525_remove_unique_constraint_from_invites_index.rb
+++ b/db/migrate/20140729092525_remove_unique_constraint_from_invites_index.rb
@@ -2,12 +2,12 @@
class RemoveUniqueConstraintFromInvitesIndex < ActiveRecord::Migration[4.2]
def up
- remove_index :invites, [:email, :invited_by_id]
- add_index :invites, [:email, :invited_by_id], unique: false
+ remove_index :invites, %i[email invited_by_id]
+ add_index :invites, %i[email invited_by_id], unique: false
end
def down
- remove_index :invites, [:email, :invited_by_id]
- add_index :invites, [:email, :invited_by_id], unique: true
+ remove_index :invites, %i[email invited_by_id]
+ add_index :invites, %i[email invited_by_id], unique: true
end
end
diff --git a/db/migrate/20140804010803_incoming_link_normalization.rb b/db/migrate/20140804010803_incoming_link_normalization.rb
index f9c6c7304c0..92fca559066 100644
--- a/db/migrate/20140804010803_incoming_link_normalization.rb
+++ b/db/migrate/20140804010803_incoming_link_normalization.rb
@@ -66,8 +66,8 @@ class IncomingLinkNormalization < ActiveRecord::Migration[4.2]
change_column :incoming_referers, :incoming_domain_id, :integer, null: false
- add_index :incoming_referers, [:path, :incoming_domain_id], unique: true
- add_index :incoming_domains, [:name, :https, :port], unique: true
+ add_index :incoming_referers, %i[path incoming_domain_id], unique: true
+ add_index :incoming_domains, %i[name https port], unique: true
remove_column :incoming_links, :referer
end
diff --git a/db/migrate/20140804072504_views_to_topic_views.rb b/db/migrate/20140804072504_views_to_topic_views.rb
index 6125b22f27b..8947ee7c35b 100644
--- a/db/migrate/20140804072504_views_to_topic_views.rb
+++ b/db/migrate/20140804072504_views_to_topic_views.rb
@@ -8,6 +8,6 @@ class ViewsToTopicViews < ActiveRecord::Migration[4.2]
rename_table :views, :topic_views
add_index :topic_views, [:topic_id]
- add_index :topic_views, [:user_id, :topic_id]
+ add_index :topic_views, %i[user_id topic_id]
end
end
diff --git a/db/migrate/20140804075613_normalize_topic_view_data_and_index.rb b/db/migrate/20140804075613_normalize_topic_view_data_and_index.rb
index 4ccc047a129..165db7a58f7 100644
--- a/db/migrate/20140804075613_normalize_topic_view_data_and_index.rb
+++ b/db/migrate/20140804075613_normalize_topic_view_data_and_index.rb
@@ -3,38 +3,38 @@
class NormalizeTopicViewDataAndIndex < ActiveRecord::Migration[4.2]
def change
remove_index :topic_views, [:topic_id]
- remove_index :topic_views, [:user_id, :topic_id]
+ remove_index :topic_views, %i[user_id topic_id]
- execute 'CREATE TEMPORARY TABLE tmp_views_user(user_id int, topic_id int, viewed_at date, ip_address inet)'
+ execute "CREATE TEMPORARY TABLE tmp_views_user(user_id int, topic_id int, viewed_at date, ip_address inet)"
- execute 'INSERT INTO tmp_views_user(user_id, topic_id, ip_address, viewed_at)
+ execute "INSERT INTO tmp_views_user(user_id, topic_id, ip_address, viewed_at)
SELECT user_id, topic_id, min(ip_address::varchar)::inet, min(viewed_at)
FROM topic_views
WHERE user_id IS NOT NULL
GROUP BY user_id, topic_id
- '
+ "
- execute 'CREATE TEMPORARY TABLE tmp_views_ip(topic_id int, viewed_at date, ip_address inet)'
+ execute "CREATE TEMPORARY TABLE tmp_views_ip(topic_id int, viewed_at date, ip_address inet)"
- execute 'INSERT INTO tmp_views_ip(topic_id, ip_address, viewed_at)
+ execute "INSERT INTO tmp_views_ip(topic_id, ip_address, viewed_at)
SELECT topic_id, ip_address, min(viewed_at)
FROM topic_views
WHERE user_id IS NULL
GROUP BY user_id, topic_id, ip_address
- '
+ "
- execute 'truncate table topic_views'
+ execute "truncate table topic_views"
- execute 'INSERT INTO topic_views(user_id, topic_id, ip_address, viewed_at)
+ execute "INSERT INTO topic_views(user_id, topic_id, ip_address, viewed_at)
SELECT user_id, topic_id, ip_address, viewed_at FROM tmp_views_user
UNION ALL
SELECT NULL, topic_id, ip_address, viewed_at FROM tmp_views_ip
- '
+ "
- execute 'CREATE UNIQUE INDEX user_id_topic_id_topic_views ON topic_views(user_id, topic_id) WHERE user_id IS NOT NULL'
- execute 'CREATE UNIQUE INDEX ip_address_topic_id_topic_views ON topic_views(ip_address, topic_id) WHERE user_id IS NULL'
+ execute "CREATE UNIQUE INDEX user_id_topic_id_topic_views ON topic_views(user_id, topic_id) WHERE user_id IS NOT NULL"
+ execute "CREATE UNIQUE INDEX ip_address_topic_id_topic_views ON topic_views(ip_address, topic_id) WHERE user_id IS NULL"
- add_index :topic_views, [:topic_id, :viewed_at]
- add_index :topic_views, [:viewed_at, :topic_id]
+ add_index :topic_views, %i[topic_id viewed_at]
+ add_index :topic_views, %i[viewed_at topic_id]
end
end
diff --git a/db/migrate/20140806003116_fixup_badge_ids.rb b/db/migrate/20140806003116_fixup_badge_ids.rb
index 9b72b0ce241..9c49454c1af 100644
--- a/db/migrate/20140806003116_fixup_badge_ids.rb
+++ b/db/migrate/20140806003116_fixup_badge_ids.rb
@@ -7,5 +7,4 @@ class FixupBadgeIds < ActiveRecord::Migration[4.2]
# badges to bump
add_column :badges, :system, :boolean, default: false, null: false
end
-
end
diff --git a/db/migrate/20140809224243_add_user_badge_unique_index.rb b/db/migrate/20140809224243_add_user_badge_unique_index.rb
index cab252960f5..bab53876ee5 100644
--- a/db/migrate/20140809224243_add_user_badge_unique_index.rb
+++ b/db/migrate/20140809224243_add_user_badge_unique_index.rb
@@ -27,7 +27,7 @@ class AddUserBadgeUniqueIndex < ActiveRecord::Migration[4.2]
)
"
- add_index :user_badges, [:badge_id, :user_id, :seq], unique: true, where: 'post_id IS NULL'
+ add_index :user_badges, %i[badge_id user_id seq], unique: true, where: "post_id IS NULL"
end
def down
diff --git a/db/migrate/20140815183851_fix_index_on_post_actions.rb b/db/migrate/20140815183851_fix_index_on_post_actions.rb
index dfba86cb263..41c9733df6a 100644
--- a/db/migrate/20140815183851_fix_index_on_post_actions.rb
+++ b/db/migrate/20140815183851_fix_index_on_post_actions.rb
@@ -2,10 +2,10 @@
class FixIndexOnPostActions < ActiveRecord::Migration[4.2]
def change
- execute 'UPDATE post_actions SET targets_topic = false WHERE targets_topic IS NULL'
+ execute "UPDATE post_actions SET targets_topic = false WHERE targets_topic IS NULL"
change_column :post_actions, :targets_topic, :boolean, default: false, null: false
- execute '
+ execute "
DELETE FROM post_actions pa
USING post_actions x
WHERE pa.user_id = x.user_id AND
@@ -15,14 +15,13 @@ class FixIndexOnPostActions < ActiveRecord::Migration[4.2]
pa.id < x.id AND
pa.deleted_at IS NULL AND
x.deleted_at IS NULL
- '
+ "
remove_index "post_actions", name: "idx_unique_actions"
add_index "post_actions",
- ["user_id", "post_action_type_id",
- "post_id", "targets_topic"],
- name: "idx_unique_actions",
- unique: true,
- where: 'deleted_at IS NULL'
+ %w[user_id post_action_type_id post_id targets_topic],
+ name: "idx_unique_actions",
+ unique: true,
+ where: "deleted_at IS NULL"
end
end
diff --git a/db/migrate/20140815191556_fix_post_actions_index_again.rb b/db/migrate/20140815191556_fix_post_actions_index_again.rb
index 71af8a587f5..d60086b185a 100644
--- a/db/migrate/20140815191556_fix_post_actions_index_again.rb
+++ b/db/migrate/20140815191556_fix_post_actions_index_again.rb
@@ -4,10 +4,9 @@ class FixPostActionsIndexAgain < ActiveRecord::Migration[4.2]
def change
remove_index "post_actions", name: "idx_unique_actions"
add_index "post_actions",
- ["user_id", "post_action_type_id",
- "post_id", "targets_topic"],
- name: "idx_unique_actions",
- unique: true,
- where: 'deleted_at IS NULL AND disagreed_at IS NULL AND deferred_at IS NULL'
+ %w[user_id post_action_type_id post_id targets_topic],
+ name: "idx_unique_actions",
+ unique: true,
+ where: "deleted_at IS NULL AND disagreed_at IS NULL AND deferred_at IS NULL"
end
end
diff --git a/db/migrate/20140815215618_add_name_lower_to_categories.rb b/db/migrate/20140815215618_add_name_lower_to_categories.rb
index 653ef234e15..e8fa249cb52 100644
--- a/db/migrate/20140815215618_add_name_lower_to_categories.rb
+++ b/db/migrate/20140815215618_add_name_lower_to_categories.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
class AddNameLowerToCategories < ActiveRecord::Migration[4.2]
-
def up
add_column :categories, :name_lower, :string, limit: 50
execute "update categories set name_lower = lower(name)"
@@ -11,5 +10,4 @@ class AddNameLowerToCategories < ActiveRecord::Migration[4.2]
def down
remove_column :categories, :name_lower
end
-
end
diff --git a/db/migrate/20140827044811_remove_nullable_dates.rb b/db/migrate/20140827044811_remove_nullable_dates.rb
index 5edc0cecae5..bb8b13a75b6 100644
--- a/db/migrate/20140827044811_remove_nullable_dates.rb
+++ b/db/migrate/20140827044811_remove_nullable_dates.rb
@@ -2,7 +2,6 @@
class RemoveNullableDates < ActiveRecord::Migration[4.2]
def up
-
# must drop so we can muck with the column
execute "DROP VIEW badge_posts"
@@ -10,7 +9,8 @@ class RemoveNullableDates < ActiveRecord::Migration[4.2]
# this is no longer the case in Rails 4, some old installs have
# this relic
# Fix it
- sql = "select table_name, column_name from information_schema.columns
+ sql =
+ "select table_name, column_name from information_schema.columns
WHERE column_name IN ('created_at','updated_at') AND
table_schema = 'public' AND
is_nullable = 'YES' AND
@@ -35,7 +35,6 @@ class RemoveNullableDates < ActiveRecord::Migration[4.2]
t.deleted_at IS NULL AND
NOT c.read_restricted AND
t.visible"
-
end
def down
diff --git a/db/migrate/20140904055702_correct_post_action_index.rb b/db/migrate/20140904055702_correct_post_action_index.rb
index d4b4384fd3b..e0ad004f96d 100644
--- a/db/migrate/20140904055702_correct_post_action_index.rb
+++ b/db/migrate/20140904055702_correct_post_action_index.rb
@@ -1,9 +1,7 @@
# frozen_string_literal: true
class CorrectPostActionIndex < ActiveRecord::Migration[4.2]
-
def up
-
# NOTE: not stored in the table yet, is_flag contains notify_user
# hardcoding, long term we can store all metadata and join for index
# This means that if we muck with flag types we need to redo this index
@@ -14,7 +12,8 @@ class CorrectPostActionIndex < ActiveRecord::Migration[4.2]
# {:off_topic=>3, :inappropriate=>4, :notify_moderators=>7, :spam=>8}
flag_ids = "3,4,7,8"
- x = execute "DELETE FROM post_actions pa
+ x =
+ execute "DELETE FROM post_actions pa
USING post_actions pa2
WHERE pa.post_action_type_id IN (#{flag_ids}) AND
pa2.post_action_type_id IN (#{flag_ids}) AND
@@ -34,10 +33,11 @@ class CorrectPostActionIndex < ActiveRecord::Migration[4.2]
puts
add_index :post_actions,
- ["user_id", "post_id", "targets_topic"],
- name: "idx_unique_flags",
- unique: true,
- where: "deleted_at IS NULL AND
+ %w[user_id post_id targets_topic],
+ name: "idx_unique_flags",
+ unique: true,
+ where:
+ "deleted_at IS NULL AND
disagreed_at IS NULL AND
deferred_at IS NULL AND
post_action_type_id IN (#{flag_ids})"
diff --git a/db/migrate/20140905055251_rename_trust_level_badges.rb b/db/migrate/20140905055251_rename_trust_level_badges.rb
index a62419c6fe7..2f8ede11f46 100644
--- a/db/migrate/20140905055251_rename_trust_level_badges.rb
+++ b/db/migrate/20140905055251_rename_trust_level_badges.rb
@@ -1,22 +1,21 @@
# frozen_string_literal: true
class RenameTrustLevelBadges < ActiveRecord::Migration[4.2]
-
def rename(id, old, new)
execute "UPDATE badges SET name = '#{new}' WHERE name = '#{old}' AND id = #{id}"
- rescue
+ rescue StandardError
puts "#{new} badge is already in use, skipping rename"
end
def up
- rename 2, 'Regular User', 'Member'
- rename 3, 'Leader', 'Regular'
- rename 4, 'Elder', 'Leader'
+ rename 2, "Regular User", "Member"
+ rename 3, "Leader", "Regular"
+ rename 4, "Elder", "Leader"
end
def down
- rename 2, 'Member', 'Regular User'
- rename 3, 'Regular', 'Leader'
- rename 4, 'Leader', 'Elder'
+ rename 2, "Member", "Regular User"
+ rename 3, "Regular", "Leader"
+ rename 4, "Leader", "Elder"
end
end
diff --git a/db/migrate/20140910130155_create_topic_user_index.rb b/db/migrate/20140910130155_create_topic_user_index.rb
index ff75229e2c8..b72971ab106 100644
--- a/db/migrate/20140910130155_create_topic_user_index.rb
+++ b/db/migrate/20140910130155_create_topic_user_index.rb
@@ -3,6 +3,6 @@
class CreateTopicUserIndex < ActiveRecord::Migration[4.2]
def change
# seems to be the most effective for joining into topics
- add_index :topic_users, [:user_id, :topic_id], unique: true
+ add_index :topic_users, %i[user_id topic_id], unique: true
end
end
diff --git a/db/migrate/20140929204155_migrate_tos_setting.rb b/db/migrate/20140929204155_migrate_tos_setting.rb
index 3ee0ccbd8c2..7085399ab99 100644
--- a/db/migrate/20140929204155_migrate_tos_setting.rb
+++ b/db/migrate/20140929204155_migrate_tos_setting.rb
@@ -4,15 +4,15 @@ class MigrateTosSetting < ActiveRecord::Migration[4.2]
def up
res = execute("SELECT * FROM site_settings WHERE name = 'tos_accept_required' AND value = 't'")
if res.present? && res.cmd_tuples > 0
- label = 'Terms of Service'
+ label = "Terms of Service"
res = execute("SELECT value FROM site_texts WHERE text_type = 'tos_signup_form_message'")
- if res.present? && res.cmd_tuples == 1
- label = res[0]['value']
- end
+ label = res[0]["value"] if res.present? && res.cmd_tuples == 1
label = PG::Connection.escape_string(label)
- execute("INSERT INTO user_fields (name, field_type, editable) VALUES ('#{label}', 'confirm', false)")
+ execute(
+ "INSERT INTO user_fields (name, field_type, editable) VALUES ('#{label}', 'confirm', false)",
+ )
end
end
end
diff --git a/db/migrate/20141211114517_fix_emoji_path.rb b/db/migrate/20141211114517_fix_emoji_path.rb
index 3538a644f06..bd474b2fbd5 100644
--- a/db/migrate/20141211114517_fix_emoji_path.rb
+++ b/db/migrate/20141211114517_fix_emoji_path.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class FixEmojiPath < ActiveRecord::Migration[4.2]
- BASE_URL = '/plugins/emoji/images/'
+ BASE_URL = "/plugins/emoji/images/"
def up
execute <<-SQL
diff --git a/db/migrate/20141222224220_fix_emoji_path_take2.rb b/db/migrate/20141222224220_fix_emoji_path_take2.rb
index 9bf3482ac4f..c3de4618cfb 100644
--- a/db/migrate/20141222224220_fix_emoji_path_take2.rb
+++ b/db/migrate/20141222224220_fix_emoji_path_take2.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
class FixEmojiPathTake2 < ActiveRecord::Migration[4.2]
- OLD_URL = '/plugins/emoji/images/'
- NEW_URL = '/images/emoji/'
+ OLD_URL = "/plugins/emoji/images/"
+ NEW_URL = "/images/emoji/"
def up
execute <<-SQL
diff --git a/db/migrate/20150106215342_remove_stars.rb b/db/migrate/20150106215342_remove_stars.rb
index d1eca4b7c41..ec391a5c116 100644
--- a/db/migrate/20150106215342_remove_stars.rb
+++ b/db/migrate/20150106215342_remove_stars.rb
@@ -13,9 +13,9 @@ class RemoveStars < ActiveRecord::Migration[4.2]
pa.post_action_type_id = 1
WHERE pa.post_id IS NULL AND tu.starred
SQL
- puts "#{r.cmd_tuples} stars were converted to bookmarks!"
+ puts "#{r.cmd_tuples} stars were converted to bookmarks!"
- execute <<SQL
+ execute <<SQL
DELETE FROM user_actions WHERE action_type = 10
SQL
diff --git a/db/migrate/20150108002354_add_liked_and_bookmarked_to_topic_user.rb b/db/migrate/20150108002354_add_liked_and_bookmarked_to_topic_user.rb
index c519060e155..8df43b8a5f6 100644
--- a/db/migrate/20150108002354_add_liked_and_bookmarked_to_topic_user.rb
+++ b/db/migrate/20150108002354_add_liked_and_bookmarked_to_topic_user.rb
@@ -20,7 +20,6 @@ class AddLikedAndBookmarkedToTopicUser < ActiveRecord::Migration[4.2]
post_action_type_id = #{type})
"
end
-
end
def down
diff --git a/db/migrate/20150108221703_group_managers.rb b/db/migrate/20150108221703_group_managers.rb
index cb56788c361..906db958095 100644
--- a/db/migrate/20150108221703_group_managers.rb
+++ b/db/migrate/20150108221703_group_managers.rb
@@ -8,6 +8,6 @@ class GroupManagers < ActiveRecord::Migration[4.2]
t.timestamps null: false
end
- add_index :group_managers, [:group_id, :user_id], unique: true
+ add_index :group_managers, %i[group_id user_id], unique: true
end
end
diff --git a/db/migrate/20150112172259_migrate_site_text_to_site_customization.rb b/db/migrate/20150112172259_migrate_site_text_to_site_customization.rb
index aa61192b3de..a7d433b0789 100644
--- a/db/migrate/20150112172259_migrate_site_text_to_site_customization.rb
+++ b/db/migrate/20150112172259_migrate_site_text_to_site_customization.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
class MigrateSiteTextToSiteCustomization < ActiveRecord::Migration[4.2]
-
def up
execute <<-SQL
DO
@@ -28,5 +27,4 @@ class MigrateSiteTextToSiteCustomization < ActiveRecord::Migration[4.2]
def down
end
-
end
diff --git a/db/migrate/20150119192813_add_posts_index_including_deleted.rb b/db/migrate/20150119192813_add_posts_index_including_deleted.rb
index a5475b67832..e37800a8803 100644
--- a/db/migrate/20150119192813_add_posts_index_including_deleted.rb
+++ b/db/migrate/20150119192813_add_posts_index_including_deleted.rb
@@ -2,6 +2,6 @@
class AddPostsIndexIncludingDeleted < ActiveRecord::Migration[4.2]
def change
- add_index :posts, [:user_id, :created_at]
+ add_index :posts, %i[user_id created_at]
end
end
diff --git a/db/migrate/20150203041207_add_application_requests.rb b/db/migrate/20150203041207_add_application_requests.rb
index d769542e4ac..3fcf2f54682 100644
--- a/db/migrate/20150203041207_add_application_requests.rb
+++ b/db/migrate/20150203041207_add_application_requests.rb
@@ -8,6 +8,6 @@ class AddApplicationRequests < ActiveRecord::Migration[4.2]
t.integer :count, null: false, default: 0
end
- add_index :application_requests, [:date, :req_type], unique: true
+ add_index :application_requests, %i[date req_type], unique: true
end
end
diff --git a/db/migrate/20150205032808_reset_application_requests.rb b/db/migrate/20150205032808_reset_application_requests.rb
index d08c7cf03ec..4fb5113caf3 100644
--- a/db/migrate/20150205032808_reset_application_requests.rb
+++ b/db/migrate/20150205032808_reset_application_requests.rb
@@ -1,10 +1,9 @@
# frozen_string_literal: true
class ResetApplicationRequests < ActiveRecord::Migration[4.2]
-
def up
# enum changed we need to clear the data
- execute 'TRUNCATE TABLE application_requests'
+ execute "TRUNCATE TABLE application_requests"
end
def down
diff --git a/db/migrate/20150213174159_create_digest_unsubscribe_keys.rb b/db/migrate/20150213174159_create_digest_unsubscribe_keys.rb
index aeb7e86dbab..fc03e2dcb6e 100644
--- a/db/migrate/20150213174159_create_digest_unsubscribe_keys.rb
+++ b/db/migrate/20150213174159_create_digest_unsubscribe_keys.rb
@@ -18,27 +18,27 @@ class CreateDigestUnsubscribeKeys < ActiveRecord::Migration[4.2]
def migrate_redis_keys
return if Rails.env.test?
- temp_keys = Discourse.redis.keys('temporary_key:*')
+ temp_keys = Discourse.redis.keys("temporary_key:*")
if temp_keys.present?
temp_keys.map! do |key|
user_id = Discourse.redis.get(key).to_i
ttl = Discourse.redis.ttl(key).to_i
if ttl > 0
- ttl = "'#{ttl.seconds.ago.strftime('%Y-%m-%d %H:%M:%S')}'"
+ ttl = "'#{ttl.seconds.ago.strftime("%Y-%m-%d %H:%M:%S")}'"
else
ttl = "CURRENT_TIMESTAMP"
end
Discourse.redis.del(key)
- key.gsub!('temporary_key:', '')
+ key.gsub!("temporary_key:", "")
user_id ? "('#{key}', #{user_id}, #{ttl}, #{ttl})" : nil
end
temp_keys.compact!
if temp_keys.present?
- execute "INSERT INTO digest_unsubscribe_keys (key, user_id, created_at, updated_at) VALUES #{temp_keys.join(', ')}"
+ execute "INSERT INTO digest_unsubscribe_keys (key, user_id, created_at, updated_at) VALUES #{temp_keys.join(", ")}"
end
end
- rescue
+ rescue StandardError
# If anything goes wrong, continue with other migrations
end
diff --git a/db/migrate/20150224004420_add_pinned_indexes.rb b/db/migrate/20150224004420_add_pinned_indexes.rb
index 4dc48416f94..929ce87e262 100644
--- a/db/migrate/20150224004420_add_pinned_indexes.rb
+++ b/db/migrate/20150224004420_add_pinned_indexes.rb
@@ -2,7 +2,7 @@
class AddPinnedIndexes < ActiveRecord::Migration[4.2]
def change
- add_index :topics, :pinned_globally, where: 'pinned_globally'
- add_index :topics, :pinned_at, where: 'pinned_at IS NOT NULL'
+ add_index :topics, :pinned_globally, where: "pinned_globally"
+ add_index :topics, :pinned_at, where: "pinned_at IS NOT NULL"
end
end
diff --git a/db/migrate/20150301224250_create_suggested_for_index.rb b/db/migrate/20150301224250_create_suggested_for_index.rb
index 2a664199f37..6fcb20e1299 100644
--- a/db/migrate/20150301224250_create_suggested_for_index.rb
+++ b/db/migrate/20150301224250_create_suggested_for_index.rb
@@ -2,7 +2,8 @@
class CreateSuggestedForIndex < ActiveRecord::Migration[4.2]
def change
- add_index :topics, [:created_at, :visible],
- where: "deleted_at IS NULL AND archetype <> 'private_message'"
+ add_index :topics,
+ %i[created_at visible],
+ where: "deleted_at IS NULL AND archetype <> 'private_message'"
end
end
diff --git a/db/migrate/20150306050437_add_all_time_and_op_likes_to_top_topics.rb b/db/migrate/20150306050437_add_all_time_and_op_likes_to_top_topics.rb
index d1db8f0e229..de76497b514 100644
--- a/db/migrate/20150306050437_add_all_time_and_op_likes_to_top_topics.rb
+++ b/db/migrate/20150306050437_add_all_time_and_op_likes_to_top_topics.rb
@@ -3,7 +3,7 @@
class AddAllTimeAndOpLikesToTopTopics < ActiveRecord::Migration[4.2]
def change
add_column :top_topics, :all_score, :float, default: 0
- [:daily, :weekly, :monthly, :yearly].each do |period|
+ %i[daily weekly monthly yearly].each do |period|
column = "#{period}_op_likes_count"
add_column :top_topics, column, :integer, default: 0, null: false
add_index :top_topics, [column]
diff --git a/db/migrate/20150323234856_add_muted_users.rb b/db/migrate/20150323234856_add_muted_users.rb
index 82a102245da..b55665d7f6b 100644
--- a/db/migrate/20150323234856_add_muted_users.rb
+++ b/db/migrate/20150323234856_add_muted_users.rb
@@ -8,7 +8,7 @@ class AddMutedUsers < ActiveRecord::Migration[4.2]
t.timestamps null: false
end
- add_index :muted_users, [:user_id, :muted_user_id], unique: true
- add_index :muted_users, [:muted_user_id, :user_id], unique: true
+ add_index :muted_users, %i[user_id muted_user_id], unique: true
+ add_index :muted_users, %i[muted_user_id user_id], unique: true
end
end
diff --git a/db/migrate/20150325190959_create_queued_posts.rb b/db/migrate/20150325190959_create_queued_posts.rb
index 4a2c199cb20..b11aa56c718 100644
--- a/db/migrate/20150325190959_create_queued_posts.rb
+++ b/db/migrate/20150325190959_create_queued_posts.rb
@@ -3,20 +3,20 @@
class CreateQueuedPosts < ActiveRecord::Migration[4.2]
def change
create_table :queued_posts, force: true do |t|
- t.string :queue, null: false
- t.integer :state, null: false
- t.integer :user_id, null: false
- t.text :raw, null: false
- t.json :post_options, null: false
- t.integer :topic_id
- t.integer :approved_by_id
- t.timestamp :approved_at
- t.integer :rejected_by_id
- t.timestamp :rejected_at
+ t.string :queue, null: false
+ t.integer :state, null: false
+ t.integer :user_id, null: false
+ t.text :raw, null: false
+ t.json :post_options, null: false
+ t.integer :topic_id
+ t.integer :approved_by_id
+ t.timestamp :approved_at
+ t.integer :rejected_by_id
+ t.timestamp :rejected_at
t.timestamps null: false
end
- add_index :queued_posts, [:queue, :state, :created_at], name: 'by_queue_status'
- add_index :queued_posts, [:topic_id, :queue, :state, :created_at], name: 'by_queue_status_topic'
+ add_index :queued_posts, %i[queue state created_at], name: "by_queue_status"
+ add_index :queued_posts, %i[topic_id queue state created_at], name: "by_queue_status_topic"
end
end
diff --git a/db/migrate/20150422160235_add_link_post_id_index_on_topic_links.rb b/db/migrate/20150422160235_add_link_post_id_index_on_topic_links.rb
index 7cb6fd73dd2..38b558b7c50 100644
--- a/db/migrate/20150422160235_add_link_post_id_index_on_topic_links.rb
+++ b/db/migrate/20150422160235_add_link_post_id_index_on_topic_links.rb
@@ -2,6 +2,6 @@
class AddLinkPostIdIndexOnTopicLinks < ActiveRecord::Migration[4.2]
def change
- add_index :topic_links, [:link_post_id, :reflection]
+ add_index :topic_links, %i[link_post_id reflection]
end
end
diff --git a/db/migrate/20150505044154_add_stylesheet_cache.rb b/db/migrate/20150505044154_add_stylesheet_cache.rb
index 9af3cbbd0a2..73d0361045f 100644
--- a/db/migrate/20150505044154_add_stylesheet_cache.rb
+++ b/db/migrate/20150505044154_add_stylesheet_cache.rb
@@ -9,6 +9,6 @@ class AddStylesheetCache < ActiveRecord::Migration[4.2]
t.timestamps null: false
end
- add_index :stylesheet_cache, [:target, :digest], unique: true
+ add_index :stylesheet_cache, %i[target digest], unique: true
end
end
diff --git a/db/migrate/20150513094042_add_index_on_post_actions.rb b/db/migrate/20150513094042_add_index_on_post_actions.rb
index fa7eafff3d0..5aead212caf 100644
--- a/db/migrate/20150513094042_add_index_on_post_actions.rb
+++ b/db/migrate/20150513094042_add_index_on_post_actions.rb
@@ -2,6 +2,6 @@
class AddIndexOnPostActions < ActiveRecord::Migration[4.2]
def change
- add_index :post_actions, [:user_id, :post_action_type_id], where: 'deleted_at IS NULL'
+ add_index :post_actions, %i[user_id post_action_type_id], where: "deleted_at IS NULL"
end
end
diff --git a/db/migrate/20150514023016_add_unread_notifications_index.rb b/db/migrate/20150514023016_add_unread_notifications_index.rb
index 237258b0a97..b21ebc43d03 100644
--- a/db/migrate/20150514023016_add_unread_notifications_index.rb
+++ b/db/migrate/20150514023016_add_unread_notifications_index.rb
@@ -2,6 +2,9 @@
class AddUnreadNotificationsIndex < ActiveRecord::Migration[4.2]
def change
- add_index :notifications, [:user_id, :notification_type], where: 'not read', name: 'idx_notifications_speedup_unread_count'
+ add_index :notifications,
+ %i[user_id notification_type],
+ where: "not read",
+ name: "idx_notifications_speedup_unread_count"
end
end
diff --git a/db/migrate/20150514043155_add_user_actions_all_index.rb b/db/migrate/20150514043155_add_user_actions_all_index.rb
index bfffe4f6205..e549cc5c5ab 100644
--- a/db/migrate/20150514043155_add_user_actions_all_index.rb
+++ b/db/migrate/20150514043155_add_user_actions_all_index.rb
@@ -2,6 +2,8 @@
class AddUserActionsAllIndex < ActiveRecord::Migration[4.2]
def change
- add_index :user_actions, [:user_id, :created_at, :action_type], name: 'idx_user_actions_speed_up_user_all'
+ add_index :user_actions,
+ %i[user_id created_at action_type],
+ name: "idx_user_actions_speed_up_user_all"
end
end
diff --git a/db/migrate/20150617080349_add_index_on_post_notifications.rb b/db/migrate/20150617080349_add_index_on_post_notifications.rb
index 1d4b980a0b3..dba012c1627 100644
--- a/db/migrate/20150617080349_add_index_on_post_notifications.rb
+++ b/db/migrate/20150617080349_add_index_on_post_notifications.rb
@@ -2,6 +2,6 @@
class AddIndexOnPostNotifications < ActiveRecord::Migration[4.2]
def change
- add_index :notifications, [:user_id, :topic_id, :post_number]
+ add_index :notifications, %i[user_id topic_id post_number]
end
end
diff --git a/db/migrate/20150617234511_add_staff_index_to_users.rb b/db/migrate/20150617234511_add_staff_index_to_users.rb
index 7d0384b73ec..f07aca8dec0 100644
--- a/db/migrate/20150617234511_add_staff_index_to_users.rb
+++ b/db/migrate/20150617234511_add_staff_index_to_users.rb
@@ -2,7 +2,7 @@
class AddStaffIndexToUsers < ActiveRecord::Migration[4.2]
def change
- add_index :users, [:id], name: 'idx_users_admin', where: 'admin'
- add_index :users, [:id], name: 'idx_users_moderator', where: 'moderator'
+ add_index :users, [:id], name: "idx_users_admin", where: "admin"
+ add_index :users, [:id], name: "idx_users_moderator", where: "moderator"
end
end
diff --git a/db/migrate/20150707163251_add_reports_index_to_user_visits.rb b/db/migrate/20150707163251_add_reports_index_to_user_visits.rb
index 803da8331ba..49ce5de3101 100644
--- a/db/migrate/20150707163251_add_reports_index_to_user_visits.rb
+++ b/db/migrate/20150707163251_add_reports_index_to_user_visits.rb
@@ -2,10 +2,10 @@
class AddReportsIndexToUserVisits < ActiveRecord::Migration[4.2]
def up
- add_index :user_visits, [:visited_at, :mobile]
+ add_index :user_visits, %i[visited_at mobile]
end
def down
- remove_index :user_visits, [:visited_at, :mobile]
+ remove_index :user_visits, %i[visited_at mobile]
end
end
diff --git a/db/migrate/20150724165259_add_index_to_post_custom_fields.rb b/db/migrate/20150724165259_add_index_to_post_custom_fields.rb
index 984eb339747..d140f0dbb12 100644
--- a/db/migrate/20150724165259_add_index_to_post_custom_fields.rb
+++ b/db/migrate/20150724165259_add_index_to_post_custom_fields.rb
@@ -11,6 +11,5 @@ SQL
execute <<SQL
DROP INDEX index_post_custom_fields_on_name_and_value
SQL
-
end
end
diff --git a/db/migrate/20150727210748_add_quarterly_to_top_topics.rb b/db/migrate/20150727210748_add_quarterly_to_top_topics.rb
index 0b4de3af974..21019a1c2fe 100644
--- a/db/migrate/20150727210748_add_quarterly_to_top_topics.rb
+++ b/db/migrate/20150727210748_add_quarterly_to_top_topics.rb
@@ -2,10 +2,10 @@
class AddQuarterlyToTopTopics < ActiveRecord::Migration[4.2]
def change
- add_column :top_topics, :quarterly_posts_count, :integer, default: 0, null: false
- add_column :top_topics, :quarterly_views_count, :integer, default: 0, null: false
- add_column :top_topics, :quarterly_likes_count, :integer, default: 0, null: false
- add_column :top_topics, :quarterly_score, :float, default: 0.0
+ add_column :top_topics, :quarterly_posts_count, :integer, default: 0, null: false
+ add_column :top_topics, :quarterly_views_count, :integer, default: 0, null: false
+ add_column :top_topics, :quarterly_likes_count, :integer, default: 0, null: false
+ add_column :top_topics, :quarterly_score, :float, default: 0.0
add_column :top_topics, :quarterly_op_likes_count, :integer, default: 0, null: false
add_index :top_topics, [:quarterly_posts_count]
diff --git a/db/migrate/20150727230537_add_example_column_comments.rb b/db/migrate/20150727230537_add_example_column_comments.rb
index 73acbb93d2a..79562da3c3a 100644
--- a/db/migrate/20150727230537_add_example_column_comments.rb
+++ b/db/migrate/20150727230537_add_example_column_comments.rb
@@ -1,21 +1,24 @@
# frozen_string_literal: true
-require 'comment_migration'
+require "comment_migration"
class AddExampleColumnComments < CommentMigration
-
def comments_up
{
posts: {
- _table: 'If you want to query public posts only, use the badge_posts view.',
- post_number: 'The position of this post in the topic. The pair (topic_id, post_number) forms a natural key on the posts table.',
- raw: 'The raw Markdown that the user entered into the composer.',
- cooked: 'The processed HTML that is presented in a topic.',
- reply_to_post_number: "If this post is a reply to another, this column is the post_number of the post it's replying to. [FKEY posts.topic_id, posts.post_number]",
- reply_quoted: 'This column is true if the post contains a quote-reply, which causes the in-reply-to indicator to be absent.',
+ _table: "If you want to query public posts only, use the badge_posts view.",
+ post_number:
+ "The position of this post in the topic. The pair (topic_id, post_number) forms a natural key on the posts table.",
+ raw: "The raw Markdown that the user entered into the composer.",
+ cooked: "The processed HTML that is presented in a topic.",
+ reply_to_post_number:
+ "If this post is a reply to another, this column is the post_number of the post it's replying to. [FKEY posts.topic_id, posts.post_number]",
+ reply_quoted:
+ "This column is true if the post contains a quote-reply, which causes the in-reply-to indicator to be absent.",
},
topics: {
- _table: "To query public topics only: SELECT ... FROM topics t LEFT INNER JOIN categories c ON (t.category_id = c.id AND c.read_restricted = false)"
+ _table:
+ "To query public topics only: SELECT ... FROM topics t LEFT INNER JOIN categories c ON (t.category_id = c.id AND c.read_restricted = false)",
},
}
end
@@ -23,5 +26,4 @@ class AddExampleColumnComments < CommentMigration
def comments_down
{}
end
-
end
diff --git a/db/migrate/20150728210202_migrate_old_moderator_posts.rb b/db/migrate/20150728210202_migrate_old_moderator_posts.rb
index f2f41a6389d..95ffb413efb 100644
--- a/db/migrate/20150728210202_migrate_old_moderator_posts.rb
+++ b/db/migrate/20150728210202_migrate_old_moderator_posts.rb
@@ -1,23 +1,22 @@
# frozen_string_literal: true
class MigrateOldModeratorPosts < ActiveRecord::Migration[4.2]
-
def migrate_key(action_code)
I18n.overrides_disabled do
- text = I18n.t("topic_statuses.#{action_code.gsub('.', '_')}")
+ text = I18n.t("topic_statuses.#{action_code.gsub(".", "_")}")
execute "UPDATE posts SET action_code = '#{action_code}', raw = '', cooked = '', post_type = 3 where post_type = 2 AND raw = #{ActiveRecord::Base.connection.quote(text)}"
end
end
def up
- migrate_key('closed.enabled')
- migrate_key('closed.disabled')
- migrate_key('archived.enabled')
- migrate_key('archived.disabled')
- migrate_key('pinned.enabled')
- migrate_key('pinned.disabled')
- migrate_key('pinned_globally.enabled')
- migrate_key('pinned_globally.disabled')
+ migrate_key("closed.enabled")
+ migrate_key("closed.disabled")
+ migrate_key("archived.enabled")
+ migrate_key("archived.disabled")
+ migrate_key("pinned.enabled")
+ migrate_key("pinned.disabled")
+ migrate_key("pinned_globally.enabled")
+ migrate_key("pinned_globally.disabled")
end
end
diff --git a/db/migrate/20150729150523_migrate_auto_close_posts.rb b/db/migrate/20150729150523_migrate_auto_close_posts.rb
index c487191d18a..572467693e5 100644
--- a/db/migrate/20150729150523_migrate_auto_close_posts.rb
+++ b/db/migrate/20150729150523_migrate_auto_close_posts.rb
@@ -5,10 +5,11 @@ class MigrateAutoClosePosts < ActiveRecord::Migration[4.2]
I18n.overrides_disabled do
strings = []
- %w(days hours lastpost_days lastpost_hours lastpost_minutes).each do |k|
- I18n.t("topic_statuses.autoclosed_enabled_#{k}").values.each do |s|
- strings << s.sub("%{count}", "\\d+")
- end
+ %w[days hours lastpost_days lastpost_hours lastpost_minutes].each do |k|
+ I18n
+ .t("topic_statuses.autoclosed_enabled_#{k}")
+ .values
+ .each { |s| strings << s.sub("%{count}", "\\d+") }
end
execute <<~SQL
@@ -16,7 +17,7 @@ class MigrateAutoClosePosts < ActiveRecord::Migration[4.2]
SET action_code = 'autoclosed.enabled'
, post_type = 3
WHERE post_type = 2
- AND (#{strings.map { |s| "raw ~* #{ActiveRecord::Base.connection.quote(s)}" }.join(' OR ')})
+ AND (#{strings.map { |s| "raw ~* #{ActiveRecord::Base.connection.quote(s)}" }.join(" OR ")})
SQL
end
end
diff --git a/db/migrate/20150802233112_add_post_stats.rb b/db/migrate/20150802233112_add_post_stats.rb
index 6e47800822d..d1e9f4b8b13 100644
--- a/db/migrate/20150802233112_add_post_stats.rb
+++ b/db/migrate/20150802233112_add_post_stats.rb
@@ -2,7 +2,6 @@
class AddPostStats < ActiveRecord::Migration[4.2]
def change
-
add_column :drafts, :revisions, :int, null: false, default: 1
create_table :post_stats do |t|
diff --git a/db/migrate/20150818190757_create_embeddable_hosts.rb b/db/migrate/20150818190757_create_embeddable_hosts.rb
index 01d2df7af34..b5d2f28af0c 100644
--- a/db/migrate/20150818190757_create_embeddable_hosts.rb
+++ b/db/migrate/20150818190757_create_embeddable_hosts.rb
@@ -9,21 +9,25 @@ class CreateEmbeddableHosts < ActiveRecord::Migration[4.2]
end
category_id = 0
- category_row = execute("SELECT c.id FROM categories AS c
+ category_row =
+ execute(
+ "SELECT c.id FROM categories AS c
INNER JOIN site_settings AS s ON s.value = c.name
- WHERE s.name = 'embed_category'")
+ WHERE s.name = 'embed_category'",
+ )
- if category_row.cmd_tuples > 0
- category_id = category_row[0]['id'].to_i
- end
+ category_id = category_row[0]["id"].to_i if category_row.cmd_tuples > 0
if category_id == 0
- category_id = execute("SELECT value FROM site_settings WHERE name = 'uncategorized_category_id'")[0]['value'].to_i
+ category_id =
+ execute("SELECT value FROM site_settings WHERE name = 'uncategorized_category_id'")[0][
+ "value"
+ ].to_i
end
embeddable_hosts = execute("SELECT value FROM site_settings WHERE name = 'embeddable_hosts'")
if embeddable_hosts && embeddable_hosts.cmd_tuples > 0
- val = embeddable_hosts[0]['value']
+ val = embeddable_hosts[0]["value"]
if val.present?
records = val.split("\n")
if records.present?
diff --git a/db/migrate/20150914021445_create_user_profile_views.rb b/db/migrate/20150914021445_create_user_profile_views.rb
index 37399c6f2c7..2c1414cf166 100644
--- a/db/migrate/20150914021445_create_user_profile_views.rb
+++ b/db/migrate/20150914021445_create_user_profile_views.rb
@@ -11,7 +11,15 @@ class CreateUserProfileViews < ActiveRecord::Migration[4.2]
add_index :user_profile_views, :user_profile_id
add_index :user_profile_views, :user_id
- add_index :user_profile_views, [:viewed_at, :ip_address, :user_profile_id], where: "user_id IS NULL", unique: true, name: 'unique_profile_view_ip'
- add_index :user_profile_views, [:viewed_at, :user_id, :user_profile_id], where: "user_id IS NOT NULL", unique: true, name: 'unique_profile_view_user'
+ add_index :user_profile_views,
+ %i[viewed_at ip_address user_profile_id],
+ where: "user_id IS NULL",
+ unique: true,
+ name: "unique_profile_view_ip"
+ add_index :user_profile_views,
+ %i[viewed_at user_id user_profile_id],
+ where: "user_id IS NOT NULL",
+ unique: true,
+ name: "unique_profile_view_user"
end
end
diff --git a/db/migrate/20150918004206_add_user_id_group_id_index_to_group_users.rb b/db/migrate/20150918004206_add_user_id_group_id_index_to_group_users.rb
index be517bebb09..6c9c900dce8 100644
--- a/db/migrate/20150918004206_add_user_id_group_id_index_to_group_users.rb
+++ b/db/migrate/20150918004206_add_user_id_group_id_index_to_group_users.rb
@@ -2,6 +2,6 @@
class AddUserIdGroupIdIndexToGroupUsers < ActiveRecord::Migration[4.2]
def change
- add_index :group_users, [:user_id, :group_id], unique: true
+ add_index :group_users, %i[user_id group_id], unique: true
end
end
diff --git a/db/migrate/20151113205046_create_translation_overrides.rb b/db/migrate/20151113205046_create_translation_overrides.rb
index 3b7f68fd2d4..933ccfc0230 100644
--- a/db/migrate/20151113205046_create_translation_overrides.rb
+++ b/db/migrate/20151113205046_create_translation_overrides.rb
@@ -9,6 +9,6 @@ class CreateTranslationOverrides < ActiveRecord::Migration[4.2]
t.timestamps null: false
end
- add_index :translation_overrides, [:locale, :translation_key], unique: true
+ add_index :translation_overrides, %i[locale translation_key], unique: true
end
end
diff --git a/db/migrate/20151201035631_add_group_mentions.rb b/db/migrate/20151201035631_add_group_mentions.rb
index 8ebe2d53649..97c34613a07 100644
--- a/db/migrate/20151201035631_add_group_mentions.rb
+++ b/db/migrate/20151201035631_add_group_mentions.rb
@@ -8,7 +8,7 @@ class AddGroupMentions < ActiveRecord::Migration[4.2]
t.timestamps null: false
end
- add_index :group_mentions, [:post_id, :group_id], unique: true
- add_index :group_mentions, [:group_id, :post_id], unique: true
+ add_index :group_mentions, %i[post_id group_id], unique: true
+ add_index :group_mentions, %i[group_id post_id], unique: true
end
end
diff --git a/db/migrate/20151218232200_add_unique_index_to_category_users.rb b/db/migrate/20151218232200_add_unique_index_to_category_users.rb
index a255ea2deb8..13e440e8595 100644
--- a/db/migrate/20151218232200_add_unique_index_to_category_users.rb
+++ b/db/migrate/20151218232200_add_unique_index_to_category_users.rb
@@ -10,14 +10,18 @@ DELETE FROM category_users cu USING category_users cu1
cu.id < cu1.id
SQL
- add_index :category_users, [:user_id, :category_id, :notification_level],
- name: 'idx_category_users_u1', unique: true
- add_index :category_users, [:category_id, :user_id, :notification_level],
- name: 'idx_category_users_u2', unique: true
+ add_index :category_users,
+ %i[user_id category_id notification_level],
+ name: "idx_category_users_u1",
+ unique: true
+ add_index :category_users,
+ %i[category_id user_id notification_level],
+ name: "idx_category_users_u2",
+ unique: true
end
def down
- remove_index :category_users, name: 'idx_category_users_u1'
- remove_index :category_users, name: 'idx_category_users_u2'
+ remove_index :category_users, name: "idx_category_users_u1"
+ remove_index :category_users, name: "idx_category_users_u2"
end
end
diff --git a/db/migrate/20151219045559_add_has_messages_to_groups.rb b/db/migrate/20151219045559_add_has_messages_to_groups.rb
index 82d064f3741..2acead6acaf 100644
--- a/db/migrate/20151219045559_add_has_messages_to_groups.rb
+++ b/db/migrate/20151219045559_add_has_messages_to_groups.rb
@@ -8,7 +8,6 @@ class AddHasMessagesToGroups < ActiveRecord::Migration[4.2]
UPDATE groups g SET has_messages = true
WHERE exists(SELECT group_id FROM topic_allowed_groups WHERE group_id = g.id)
SQL
-
end
def down
diff --git a/db/migrate/20151220232725_add_user_archived_messages_group_archived_messages.rb b/db/migrate/20151220232725_add_user_archived_messages_group_archived_messages.rb
index 3110c726f82..cd0fe69b18a 100644
--- a/db/migrate/20151220232725_add_user_archived_messages_group_archived_messages.rb
+++ b/db/migrate/20151220232725_add_user_archived_messages_group_archived_messages.rb
@@ -8,7 +8,7 @@ class AddUserArchivedMessagesGroupArchivedMessages < ActiveRecord::Migration[4.2
t.timestamps null: false
end
- add_index :user_archived_messages, [:user_id, :topic_id], unique: true
+ add_index :user_archived_messages, %i[user_id topic_id], unique: true
create_table :group_archived_messages do |t|
t.integer :group_id, null: false
@@ -16,6 +16,6 @@ class AddUserArchivedMessagesGroupArchivedMessages < ActiveRecord::Migration[4.2
t.timestamps null: false
end
- add_index :group_archived_messages, [:group_id, :topic_id], unique: true
+ add_index :group_archived_messages, %i[group_id topic_id], unique: true
end
end
diff --git a/db/migrate/20160108051129_fix_incorrect_user_history.rb b/db/migrate/20160108051129_fix_incorrect_user_history.rb
index 5e2928d2586..e7062993b2e 100644
--- a/db/migrate/20160108051129_fix_incorrect_user_history.rb
+++ b/db/migrate/20160108051129_fix_incorrect_user_history.rb
@@ -16,17 +16,24 @@ class FixIncorrectUserHistory < ActiveRecord::Migration[4.2]
(action = 19 AND target_user_id IS NULL AND details IS NOT NULL)
SQL
- first_wrong_id = execute("SELECT min(id) FROM user_histories WHERE #{condition}").values[0][0].to_i
- last_wrong_id = execute("SELECT max(id) FROM user_histories WHERE #{condition}").values[0][0].to_i
+ first_wrong_id =
+ execute("SELECT min(id) FROM user_histories WHERE #{condition}").values[0][0].to_i
+ last_wrong_id =
+ execute("SELECT max(id) FROM user_histories WHERE #{condition}").values[0][0].to_i
if first_wrong_id < last_wrong_id
- msg = "Correcting user history records from id: #{first_wrong_id} to #{last_wrong_id} (see: https://meta.discourse.org/t/old-user-suspension-reasons-have-gone-missing/3730)"
+ msg =
+ "Correcting user history records from id: #{first_wrong_id} to #{last_wrong_id} (see: https://meta.discourse.org/t/old-user-suspension-reasons-have-gone-missing/3730)"
- execute("UPDATE user_histories SET action = action - 1
- WHERE action > 5 AND id >= #{first_wrong_id} AND id <= #{last_wrong_id}")
+ execute(
+ "UPDATE user_histories SET action = action - 1
+ WHERE action > 5 AND id >= #{first_wrong_id} AND id <= #{last_wrong_id}",
+ )
- execute("INSERT INTO user_histories(action, acting_user_id, details, created_at, updated_at)
- VALUES (22, -1, '#{msg}', current_timestamp, current_timestamp)")
+ execute(
+ "INSERT INTO user_histories(action, acting_user_id, details, created_at, updated_at)
+ VALUES (22, -1, '#{msg}', current_timestamp, current_timestamp)",
+ )
end
end
diff --git a/db/migrate/20160110053003_archive_system_messages_with_no_replies.rb b/db/migrate/20160110053003_archive_system_messages_with_no_replies.rb
index 8c88c345e17..dcc9361a8bf 100644
--- a/db/migrate/20160110053003_archive_system_messages_with_no_replies.rb
+++ b/db/migrate/20160110053003_archive_system_messages_with_no_replies.rb
@@ -18,7 +18,6 @@ class ArchiveSystemMessagesWithNoReplies < ActiveRecord::Migration[4.2]
p.topic_id IS NOT NULL AND
p.post_number = 1
SQL
-
end
def down
diff --git a/db/migrate/20160112025852_remove_users_from_topic_allowed_users.rb b/db/migrate/20160112025852_remove_users_from_topic_allowed_users.rb
index 1dde0a2edd2..cbfb1d9050e 100644
--- a/db/migrate/20160112025852_remove_users_from_topic_allowed_users.rb
+++ b/db/migrate/20160112025852_remove_users_from_topic_allowed_users.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
class RemoveUsersFromTopicAllowedUsers < ActiveRecord::Migration[4.2]
-
# historically we added admins automatically to a message if they
# responded, despite them being in the group the message is targeted at
# this causes inbox bloat for pretty much no reason
diff --git a/db/migrate/20160215075528_add_unread_pm_index_to_notifications.rb b/db/migrate/20160215075528_add_unread_pm_index_to_notifications.rb
index 6e9d7aa45a1..ebf1688dc09 100644
--- a/db/migrate/20160215075528_add_unread_pm_index_to_notifications.rb
+++ b/db/migrate/20160215075528_add_unread_pm_index_to_notifications.rb
@@ -3,6 +3,9 @@
class AddUnreadPmIndexToNotifications < ActiveRecord::Migration[4.2]
def change
# create index idxtmp on notifications(user_id, id) where notification_type = 6 AND NOT read
- add_index :notifications, [:user_id, :id], unique: true, where: 'notification_type = 6 AND NOT read'
+ add_index :notifications,
+ %i[user_id id],
+ unique: true,
+ where: "notification_type = 6 AND NOT read"
end
end
diff --git a/db/migrate/20160225050317_add_user_options.rb b/db/migrate/20160225050317_add_user_options.rb
index ec1c17536eb..acdef7fd10e 100644
--- a/db/migrate/20160225050317_add_user_options.rb
+++ b/db/migrate/20160225050317_add_user_options.rb
@@ -2,7 +2,6 @@
class AddUserOptions < ActiveRecord::Migration[4.2]
def up
-
create_table :user_options, id: false do |t|
t.integer :user_id, null: false
t.boolean :email_always, null: false, default: false
diff --git a/db/migrate/20160225095306_add_email_in_reply_to_to_user_options.rb b/db/migrate/20160225095306_add_email_in_reply_to_to_user_options.rb
index 7a8be0e9a2e..aeccb1840ff 100644
--- a/db/migrate/20160225095306_add_email_in_reply_to_to_user_options.rb
+++ b/db/migrate/20160225095306_add_email_in_reply_to_to_user_options.rb
@@ -4,7 +4,7 @@ class AddEmailInReplyToToUserOptions < ActiveRecord::Migration[4.2]
def up
add_column :user_options, :email_in_reply_to, :boolean, null: false, default: true
change_column :user_options, :email_previous_replies, :integer, default: 2, null: false
- execute 'UPDATE user_options SET email_previous_replies = 2'
+ execute "UPDATE user_options SET email_previous_replies = 2"
end
def down
diff --git a/db/migrate/20160302063432_rebuild_directory_item_with_index.rb b/db/migrate/20160302063432_rebuild_directory_item_with_index.rb
index 0b2836bc71f..3503836afb2 100644
--- a/db/migrate/20160302063432_rebuild_directory_item_with_index.rb
+++ b/db/migrate/20160302063432_rebuild_directory_item_with_index.rb
@@ -4,11 +4,11 @@ class RebuildDirectoryItemWithIndex < ActiveRecord::Migration[4.2]
def up
remove_index :directory_items, [:period_type]
execute "TRUNCATE TABLE directory_items RESTART IDENTITY"
- add_index :directory_items, [:period_type, :user_id], unique: true
+ add_index :directory_items, %i[period_type user_id], unique: true
end
def down
- remove_index :directory_items, [:period_type, :user_id]
+ remove_index :directory_items, %i[period_type user_id]
add_index :directory_items, [:period_type]
end
end
diff --git a/db/migrate/20160317174357_create_given_daily_likes.rb b/db/migrate/20160317174357_create_given_daily_likes.rb
index 755256efccb..34b93d52ba8 100644
--- a/db/migrate/20160317174357_create_given_daily_likes.rb
+++ b/db/migrate/20160317174357_create_given_daily_likes.rb
@@ -5,16 +5,14 @@ class CreateGivenDailyLikes < ActiveRecord::Migration[4.2]
create_table :given_daily_likes, id: false, force: true do |t|
t.integer :user_id, null: false
t.integer :likes_given, null: false
- t.date :given_date, null: false
+ t.date :given_date, null: false
t.boolean :limit_reached, null: false, default: false
end
- add_index :given_daily_likes, [:user_id, :given_date], unique: true
- add_index :given_daily_likes, [:limit_reached, :user_id]
+ add_index :given_daily_likes, %i[user_id given_date], unique: true
+ add_index :given_daily_likes, %i[limit_reached user_id]
max_likes_rows = execute("SELECT value FROM site_settings WHERE name = 'max_likes_per_day'")
- if max_likes_rows && max_likes_rows.cmd_tuples > 0
- max_likes = max_likes_rows[0]['value'].to_i
- end
+ max_likes = max_likes_rows[0]["value"].to_i if max_likes_rows && max_likes_rows.cmd_tuples > 0
max_likes ||= 50
execute "INSERT INTO given_daily_likes (user_id, likes_given, limit_reached, given_date)
diff --git a/db/migrate/20160405172827_create_user_firsts.rb b/db/migrate/20160405172827_create_user_firsts.rb
index 8a5789f29c7..886faf1135f 100644
--- a/db/migrate/20160405172827_create_user_firsts.rb
+++ b/db/migrate/20160405172827_create_user_firsts.rb
@@ -9,6 +9,6 @@ class CreateUserFirsts < ActiveRecord::Migration[4.2]
t.datetime :created_at, null: false
end
- add_index :user_firsts, [:user_id, :first_type], unique: true
+ add_index :user_firsts, %i[user_id first_type], unique: true
end
end
diff --git a/db/migrate/20160407160756_remove_user_firsts.rb b/db/migrate/20160407160756_remove_user_firsts.rb
index d3c7d51b957..e09b77250c5 100644
--- a/db/migrate/20160407160756_remove_user_firsts.rb
+++ b/db/migrate/20160407160756_remove_user_firsts.rb
@@ -3,7 +3,7 @@
class RemoveUserFirsts < ActiveRecord::Migration[4.2]
def up
drop_table(:user_firsts) if table_exists?(:user_firsts)
- rescue
+ rescue StandardError
# continues with other migrations if we can't delete that table
nil
end
diff --git a/db/migrate/20160503205953_create_tags.rb b/db/migrate/20160503205953_create_tags.rb
index b04a91ff090..cfa6a0200bc 100644
--- a/db/migrate/20160503205953_create_tags.rb
+++ b/db/migrate/20160503205953_create_tags.rb
@@ -3,27 +3,33 @@
class CreateTags < ActiveRecord::Migration[4.2]
def change
create_table :tags do |t|
- t.string :name, null: false
- t.integer :topic_count, null: false, default: 0
+ t.string :name, null: false
+ t.integer :topic_count, null: false, default: 0
t.timestamps null: false
end
create_table :topic_tags do |t|
t.references :topic, null: false
- t.references :tag, null: false
+ t.references :tag, null: false
t.timestamps null: false
end
create_table :tag_users do |t|
- t.references :tag, null: false
+ t.references :tag, null: false
t.references :user, null: false
- t.integer :notification_level, null: false
+ t.integer :notification_level, null: false
t.timestamps null: false
end
add_index :tags, :name, unique: true
- add_index :topic_tags, [:topic_id, :tag_id], unique: true
- add_index :tag_users, [:user_id, :tag_id, :notification_level], name: "idx_tag_users_ix1", unique: true
- add_index :tag_users, [:tag_id, :user_id, :notification_level], name: "idx_tag_users_ix2", unique: true
+ add_index :topic_tags, %i[topic_id tag_id], unique: true
+ add_index :tag_users,
+ %i[user_id tag_id notification_level],
+ name: "idx_tag_users_ix1",
+ unique: true
+ add_index :tag_users,
+ %i[tag_id user_id notification_level],
+ name: "idx_tag_users_ix2",
+ unique: true
end
end
diff --git a/db/migrate/20160520022627_shorten_topic_custom_fields_index.rb b/db/migrate/20160520022627_shorten_topic_custom_fields_index.rb
index 8918d254723..c3371cf4266 100644
--- a/db/migrate/20160520022627_shorten_topic_custom_fields_index.rb
+++ b/db/migrate/20160520022627_shorten_topic_custom_fields_index.rb
@@ -3,12 +3,13 @@
class ShortenTopicCustomFieldsIndex < ActiveRecord::Migration[4.2]
def up
remove_index :topic_custom_fields, :value
- add_index :topic_custom_fields, [:value, :name],
- name: 'topic_custom_fields_value_key_idx',
- where: 'value IS NOT NULL AND char_length(value) < 400'
+ add_index :topic_custom_fields,
+ %i[value name],
+ name: "topic_custom_fields_value_key_idx",
+ where: "value IS NOT NULL AND char_length(value) < 400"
end
def down
- remove_index :topic_custom_fields, :value, name: 'topic_custom_fields_value_key_idx'
+ remove_index :topic_custom_fields, :value, name: "topic_custom_fields_value_key_idx"
add_index :topic_custom_fields, :value
end
end
diff --git a/db/migrate/20160527015355_correct_mailing_list_mode_frequency.rb b/db/migrate/20160527015355_correct_mailing_list_mode_frequency.rb
index f19cdb0d385..7d1f9135bad 100644
--- a/db/migrate/20160527015355_correct_mailing_list_mode_frequency.rb
+++ b/db/migrate/20160527015355_correct_mailing_list_mode_frequency.rb
@@ -4,7 +4,7 @@ class CorrectMailingListModeFrequency < ActiveRecord::Migration[4.2]
def up
# historically mailing list mode was for every message
# keep working the same way for all old users
- execute 'UPDATE user_options SET mailing_list_mode_frequency = 1 where mailing_list_mode'
+ execute "UPDATE user_options SET mailing_list_mode_frequency = 1 where mailing_list_mode"
end
def down
diff --git a/db/migrate/20160527191614_create_category_tags.rb b/db/migrate/20160527191614_create_category_tags.rb
index 9675a4ce1ef..0a52730f062 100644
--- a/db/migrate/20160527191614_create_category_tags.rb
+++ b/db/migrate/20160527191614_create_category_tags.rb
@@ -4,11 +4,11 @@ class CreateCategoryTags < ActiveRecord::Migration[4.2]
def change
create_table :category_tags do |t|
t.references :category, null: false
- t.references :tag, null: false
+ t.references :tag, null: false
t.timestamps null: false
end
- add_index :category_tags, [:category_id, :tag_id], name: "idx_category_tags_ix1", unique: true
- add_index :category_tags, [:tag_id, :category_id], name: "idx_category_tags_ix2", unique: true
+ add_index :category_tags, %i[category_id tag_id], name: "idx_category_tags_ix1", unique: true
+ add_index :category_tags, %i[tag_id category_id], name: "idx_category_tags_ix2", unique: true
end
end
diff --git a/db/migrate/20160602164008_create_tag_groups.rb b/db/migrate/20160602164008_create_tag_groups.rb
index 13e2cfdafdf..685fdbc9be3 100644
--- a/db/migrate/20160602164008_create_tag_groups.rb
+++ b/db/migrate/20160602164008_create_tag_groups.rb
@@ -3,17 +3,17 @@
class CreateTagGroups < ActiveRecord::Migration[4.2]
def change
create_table :tag_groups do |t|
- t.string :name, null: false
+ t.string :name, null: false
t.integer :tag_count, null: false, default: 0
t.timestamps null: false
end
create_table :tag_group_memberships do |t|
- t.references :tag, null: false
+ t.references :tag, null: false
t.references :tag_group, null: false
t.timestamps null: false
end
- add_index :tag_group_memberships, [:tag_group_id, :tag_id], unique: true
+ add_index :tag_group_memberships, %i[tag_group_id tag_id], unique: true
end
end
diff --git a/db/migrate/20160606204319_create_category_tag_groups.rb b/db/migrate/20160606204319_create_category_tag_groups.rb
index e6c8a9db291..ed7b3678c30 100644
--- a/db/migrate/20160606204319_create_category_tag_groups.rb
+++ b/db/migrate/20160606204319_create_category_tag_groups.rb
@@ -3,11 +3,14 @@
class CreateCategoryTagGroups < ActiveRecord::Migration[4.2]
def change
create_table :category_tag_groups do |t|
- t.references :category, null: false
+ t.references :category, null: false
t.references :tag_group, null: false
t.timestamps null: false
end
- add_index :category_tag_groups, [:category_id, :tag_group_id], name: "idx_category_tag_groups_ix1", unique: true
+ add_index :category_tag_groups,
+ %i[category_id tag_group_id],
+ name: "idx_category_tag_groups_ix1",
+ unique: true
end
end
diff --git a/db/migrate/20160719002225_add_deleted_post_index_to_posts.rb b/db/migrate/20160719002225_add_deleted_post_index_to_posts.rb
index df3139d70c5..0ee9f6050d6 100644
--- a/db/migrate/20160719002225_add_deleted_post_index_to_posts.rb
+++ b/db/migrate/20160719002225_add_deleted_post_index_to_posts.rb
@@ -2,6 +2,9 @@
class AddDeletedPostIndexToPosts < ActiveRecord::Migration[4.2]
def change
- add_index :posts, [:topic_id, :post_number], where: 'deleted_at IS NOT NULL', name: 'idx_posts_deleted_posts'
+ add_index :posts,
+ %i[topic_id post_number],
+ where: "deleted_at IS NOT NULL",
+ name: "idx_posts_deleted_posts"
end
end
diff --git a/db/migrate/20160815210156_add_flair_url_to_groups.rb b/db/migrate/20160815210156_add_flair_url_to_groups.rb
index b678f03d067..02b7cb69910 100644
--- a/db/migrate/20160815210156_add_flair_url_to_groups.rb
+++ b/db/migrate/20160815210156_add_flair_url_to_groups.rb
@@ -2,7 +2,7 @@
class AddFlairUrlToGroups < ActiveRecord::Migration[4.2]
def change
- add_column :groups, :flair_url, :string
+ add_column :groups, :flair_url, :string
add_column :groups, :flair_bg_color, :string
end
end
diff --git a/db/migrate/20160905082248_create_web_hooks.rb b/db/migrate/20160905082248_create_web_hooks.rb
index f98f2c0e0b8..ff88d731bef 100644
--- a/db/migrate/20160905082248_create_web_hooks.rb
+++ b/db/migrate/20160905082248_create_web_hooks.rb
@@ -3,11 +3,11 @@
class CreateWebHooks < ActiveRecord::Migration[4.2]
def change
create_table :web_hooks do |t|
- t.string :payload_url, null: false
+ t.string :payload_url, null: false
t.integer :content_type, default: 1, null: false
t.integer :last_delivery_status, default: 1, null: false
t.integer :status, default: 1, null: false
- t.string :secret, default: ''
+ t.string :secret, default: ""
t.boolean :wildcard_web_hook, default: false, null: false
t.boolean :verify_certificate, default: true, null: false
t.boolean :active, default: false, null: false
diff --git a/db/migrate/20160905084502_create_web_hook_events.rb b/db/migrate/20160905084502_create_web_hook_events.rb
index a82721308f5..d4d8b6dd8f0 100644
--- a/db/migrate/20160905084502_create_web_hook_events.rb
+++ b/db/migrate/20160905084502_create_web_hook_events.rb
@@ -4,12 +4,12 @@ class CreateWebHookEvents < ActiveRecord::Migration[4.2]
def change
create_table :web_hook_events do |t|
t.belongs_to :web_hook, null: false, index: true
- t.string :headers
- t.text :payload
- t.integer :status, default: 0
- t.string :response_headers
- t.text :response_body
- t.integer :duration, default: 0
+ t.string :headers
+ t.text :payload
+ t.integer :status, default: 0
+ t.string :response_headers
+ t.text :response_body
+ t.integer :duration, default: 0
t.timestamps null: false
end
diff --git a/db/migrate/20160905085445_create_join_table_web_hooks_web_hook_event_types.rb b/db/migrate/20160905085445_create_join_table_web_hooks_web_hook_event_types.rb
index f28ef31671a..84db92b31b3 100644
--- a/db/migrate/20160905085445_create_join_table_web_hooks_web_hook_event_types.rb
+++ b/db/migrate/20160905085445_create_join_table_web_hooks_web_hook_event_types.rb
@@ -4,8 +4,9 @@ class CreateJoinTableWebHooksWebHookEventTypes < ActiveRecord::Migration[4.2]
def change
create_join_table :web_hooks, :web_hook_event_types
- add_index :web_hook_event_types_hooks, [:web_hook_event_type_id, :web_hook_id],
- name: 'idx_web_hook_event_types_hooks_on_ids',
- unique: true
+ add_index :web_hook_event_types_hooks,
+ %i[web_hook_event_type_id web_hook_id],
+ name: "idx_web_hook_event_types_hooks_on_ids",
+ unique: true
end
end
diff --git a/db/migrate/20160905091958_create_join_table_web_hooks_groups.rb b/db/migrate/20160905091958_create_join_table_web_hooks_groups.rb
index 17e6b2a12d6..4c8aaed95ba 100644
--- a/db/migrate/20160905091958_create_join_table_web_hooks_groups.rb
+++ b/db/migrate/20160905091958_create_join_table_web_hooks_groups.rb
@@ -3,6 +3,6 @@
class CreateJoinTableWebHooksGroups < ActiveRecord::Migration[4.2]
def change
create_join_table :web_hooks, :groups
- add_index :groups_web_hooks, [:web_hook_id, :group_id], unique: true
+ add_index :groups_web_hooks, %i[web_hook_id group_id], unique: true
end
end
diff --git a/db/migrate/20160905092148_create_join_table_web_hooks_categories.rb b/db/migrate/20160905092148_create_join_table_web_hooks_categories.rb
index 328aa3c25ab..7a43d807408 100644
--- a/db/migrate/20160905092148_create_join_table_web_hooks_categories.rb
+++ b/db/migrate/20160905092148_create_join_table_web_hooks_categories.rb
@@ -3,6 +3,6 @@
class CreateJoinTableWebHooksCategories < ActiveRecord::Migration[4.2]
def change
create_join_table :web_hooks, :categories
- add_index :categories_web_hooks, [:web_hook_id, :category_id], unique: true
+ add_index :categories_web_hooks, %i[web_hook_id category_id], unique: true
end
end
diff --git a/db/migrate/20161205001727_add_topic_columns_back.rb b/db/migrate/20161205001727_add_topic_columns_back.rb
index 7e3ba350697..e533a4b6490 100644
--- a/db/migrate/20161205001727_add_topic_columns_back.rb
+++ b/db/migrate/20161205001727_add_topic_columns_back.rb
@@ -1,23 +1,22 @@
# frozen_string_literal: true
class AddTopicColumnsBack < ActiveRecord::Migration[4.2]
-
# This really sucks big time, we have no use for these columns yet can not remove them
# if we remove them then sites will be down during migration
def up
add_column :topics, :bookmark_count, :int
- add_column :topics, :off_topic_count, :int
- add_column :topics, :illegal_count, :int
- add_column :topics, :inappropriate_count, :int
- add_column :topics, :notify_user_count, :int
+ add_column :topics, :off_topic_count, :int
+ add_column :topics, :illegal_count, :int
+ add_column :topics, :inappropriate_count, :int
+ add_column :topics, :notify_user_count, :int
end
def down
remove_column :topics, :bookmark_count
- remove_column :topics, :off_topic_count
- remove_column :topics, :illegal_count
- remove_column :topics, :inappropriate_count
- remove_column :topics, :notify_user_count
+ remove_column :topics, :off_topic_count
+ remove_column :topics, :illegal_count
+ remove_column :topics, :inappropriate_count
+ remove_column :topics, :notify_user_count
end
end
diff --git a/db/migrate/20170124181409_add_user_auth_tokens.rb b/db/migrate/20170124181409_add_user_auth_tokens.rb
index 0aabc3b6c17..9ca46e68979 100644
--- a/db/migrate/20170124181409_add_user_auth_tokens.rb
+++ b/db/migrate/20170124181409_add_user_auth_tokens.rb
@@ -11,18 +11,17 @@ class AddUserAuthTokens < ActiveRecord::Migration[4.2]
SQL
drop_table :user_auth_tokens
-
end
def up
create_table :user_auth_tokens do |t|
t.integer :user_id, null: false
- t.string :auth_token, null: false
- t.string :prev_auth_token, null: false
- t.string :user_agent
+ t.string :auth_token, null: false
+ t.string :prev_auth_token, null: false
+ t.string :user_agent
t.boolean :auth_token_seen, default: false, null: false
t.boolean :legacy, default: false, null: false
- t.inet :client_ip
+ t.inet :client_ip
t.datetime :rotated_at, null: false
t.timestamps null: false
end
diff --git a/db/migrate/20170221204204_add_show_subcategory_list_to_categories.rb b/db/migrate/20170221204204_add_show_subcategory_list_to_categories.rb
index 3fe4c73d8cd..4bc76152cc4 100644
--- a/db/migrate/20170221204204_add_show_subcategory_list_to_categories.rb
+++ b/db/migrate/20170221204204_add_show_subcategory_list_to_categories.rb
@@ -4,7 +4,10 @@ class AddShowSubcategoryListToCategories < ActiveRecord::Migration[4.2]
def up
add_column :categories, :show_subcategory_list, :boolean, default: false
- result = execute("select count(1) from site_settings where name = 'show_subcategory_list' and value = 't'")
+ result =
+ execute(
+ "select count(1) from site_settings where name = 'show_subcategory_list' and value = 't'",
+ )
if result[0] && result[0]["count"].to_i > (0)
execute "UPDATE categories SET show_subcategory_list = true WHERE parent_category_id IS NULL"
end
diff --git a/db/migrate/20170227211458_add_featured_topics_to_categories.rb b/db/migrate/20170227211458_add_featured_topics_to_categories.rb
index abcc021e77a..011c4b9a0b9 100644
--- a/db/migrate/20170227211458_add_featured_topics_to_categories.rb
+++ b/db/migrate/20170227211458_add_featured_topics_to_categories.rb
@@ -4,7 +4,10 @@ class AddFeaturedTopicsToCategories < ActiveRecord::Migration[4.2]
def up
add_column :categories, :num_featured_topics, :integer, default: 3
- result = execute("select value from site_settings where name = 'category_featured_topics' and value != '3'")
+ result =
+ execute(
+ "select value from site_settings where name = 'category_featured_topics' and value != '3'",
+ )
if result.count > 0 && result[0]["value"].to_i > 0
execute "UPDATE categories SET num_featured_topics = #{result[0]["value"].to_i}"
end
diff --git a/db/migrate/20170303070706_add_index_to_topic_view_items.rb b/db/migrate/20170303070706_add_index_to_topic_view_items.rb
index 164505e9f18..667752ea08d 100644
--- a/db/migrate/20170303070706_add_index_to_topic_view_items.rb
+++ b/db/migrate/20170303070706_add_index_to_topic_view_items.rb
@@ -2,6 +2,6 @@
class AddIndexToTopicViewItems < ActiveRecord::Migration[4.2]
def change
- add_index :topic_views, [:user_id, :viewed_at]
+ add_index :topic_views, %i[user_id viewed_at]
end
end
diff --git a/db/migrate/20170308201552_add_subcategory_list_style_to_categories.rb b/db/migrate/20170308201552_add_subcategory_list_style_to_categories.rb
index a2e91105970..9a79f388339 100644
--- a/db/migrate/20170308201552_add_subcategory_list_style_to_categories.rb
+++ b/db/migrate/20170308201552_add_subcategory_list_style_to_categories.rb
@@ -2,9 +2,16 @@
class AddSubcategoryListStyleToCategories < ActiveRecord::Migration[4.2]
def up
- add_column :categories, :subcategory_list_style, :string, limit: 50, default: 'rows_with_featured_topics'
+ add_column :categories,
+ :subcategory_list_style,
+ :string,
+ limit: 50,
+ default: "rows_with_featured_topics"
- result = execute("select value from site_settings where name = 'desktop_category_page_style' and value != 'categories_with_featured_topics'")
+ result =
+ execute(
+ "select value from site_settings where name = 'desktop_category_page_style' and value != 'categories_with_featured_topics'",
+ )
if result.count > 0
execute "UPDATE categories SET subcategory_list_style = 'rows' WHERE parent_category_id IS NULL"
end
diff --git a/db/migrate/20170313192741_add_themes.rb b/db/migrate/20170313192741_add_themes.rb
index 54c735e7186..0e3a3421749 100644
--- a/db/migrate/20170313192741_add_themes.rb
+++ b/db/migrate/20170313192741_add_themes.rb
@@ -14,27 +14,23 @@ class AddThemes < ActiveRecord::Migration[4.2]
t.timestamps null: false
end
- add_index :child_themes, [:parent_theme_id, :child_theme_id], unique: true
- add_index :child_themes, [:child_theme_id, :parent_theme_id], unique: true
+ add_index :child_themes, %i[parent_theme_id child_theme_id], unique: true
+ add_index :child_themes, %i[child_theme_id parent_theme_id], unique: true
# versioning in color scheme table was very confusing, remove it
execute "DELETE FROM color_schemes WHERE versioned_id IS NOT NULL"
remove_column :color_schemes, :versioned_id
- enabled_theme_count = execute("SELECT count(*) FROM themes WHERE enabled")
- .to_a[0]["count"].to_i
+ enabled_theme_count = execute("SELECT count(*) FROM themes WHERE enabled").to_a[0]["count"].to_i
- enabled_scheme_id = execute("SELECT id FROM color_schemes WHERE enabled")
- .to_a[0]&.fetch("id")
+ enabled_scheme_id = execute("SELECT id FROM color_schemes WHERE enabled").to_a[0]&.fetch("id")
- theme_key, theme_id =
- execute("SELECT key, id FROM themes WHERE enabled").to_a[0]&.values
+ theme_key, theme_id = execute("SELECT key, id FROM themes WHERE enabled").to_a[0]&.values
if (enabled_theme_count == 0 && enabled_scheme_id) || enabled_theme_count > 1
-
puts "Creating a new default theme!"
- theme_key = '7e202ef2-6666-47d5-98d8-a9c8d15e57dd'
+ theme_key = "7e202ef2-6666-47d5-98d8-a9c8d15e57dd"
sql = <<SQL
INSERT INTO themes(name,created_at,updated_at, enabled, key, user_id)
@@ -46,13 +42,11 @@ SQL
theme_id = execute(sql).to_a[0]["id"].to_i
end
- if enabled_theme_count > 1
- execute <<SQL
+ execute <<SQL if enabled_theme_count > 1
INSERT INTO child_themes(parent_theme_id, child_theme_id, created_at, updated_at)
SELECT #{theme_id.to_i}, id, created_at, updated_at
FROM themes WHERE enabled
SQL
- end
if enabled_scheme_id
execute "UPDATE themes SET color_scheme_id=#{enabled_scheme_id.to_i} WHERE id=#{theme_id.to_i}"
diff --git a/db/migrate/20170322191305_add_default_top_period_to_categories.rb b/db/migrate/20170322191305_add_default_top_period_to_categories.rb
index 92480da3dc7..8847a7fd00a 100644
--- a/db/migrate/20170322191305_add_default_top_period_to_categories.rb
+++ b/db/migrate/20170322191305_add_default_top_period_to_categories.rb
@@ -2,6 +2,6 @@
class AddDefaultTopPeriodToCategories < ActiveRecord::Migration[4.2]
def change
- add_column :categories, :default_top_period, :string, limit: 20, default: 'all'
+ add_column :categories, :default_top_period, :string, limit: 20, default: "all"
end
end
diff --git a/db/migrate/20170328163918_break_up_themes_table.rb b/db/migrate/20170328163918_break_up_themes_table.rb
index 498542d0b63..ad2c2d03ee5 100644
--- a/db/migrate/20170328163918_break_up_themes_table.rb
+++ b/db/migrate/20170328163918_break_up_themes_table.rb
@@ -11,7 +11,7 @@ class BreakUpThemesTable < ActiveRecord::Migration[4.2]
t.timestamps null: false
end
- add_index :theme_fields, [:theme_id, :target, :name], unique: true
+ add_index :theme_fields, %i[theme_id target name], unique: true
[
[0, "embedded_scss", "embedded_scss"],
@@ -27,7 +27,6 @@ class BreakUpThemesTable < ActiveRecord::Migration[4.2]
[1, "footer", "footer"],
[2, "mobile_footer", "footer"],
].each do |target, value, name|
-
execute <<SQL
INSERT INTO theme_fields (
theme_id,
@@ -43,14 +42,13 @@ SQL
remove_column :themes, value
end
- %w{ head_tag_baked
- body_tag_baked
- header_baked
- footer_baked
- mobile_footer_baked
- mobile_header_baked
- }.each do |col|
- remove_column :themes, col
- end
+ %w[
+ head_tag_baked
+ body_tag_baked
+ header_baked
+ footer_baked
+ mobile_footer_baked
+ mobile_header_baked
+ ].each { |col| remove_column :themes, col }
end
end
diff --git a/db/migrate/20170420163628_add_default_notification_level_to_group.rb b/db/migrate/20170420163628_add_default_notification_level_to_group.rb
index 42a930baa1c..db1d46a5eb0 100644
--- a/db/migrate/20170420163628_add_default_notification_level_to_group.rb
+++ b/db/migrate/20170420163628_add_default_notification_level_to_group.rb
@@ -4,7 +4,7 @@ class AddDefaultNotificationLevelToGroup < ActiveRecord::Migration[4.2]
def up
add_column :groups, :default_notification_level, :integer, default: 3, null: false
# don't auto watch 'moderators' it is just way too loud
- execute 'UPDATE groups SET default_notification_level = 2 WHERE id = 2'
+ execute "UPDATE groups SET default_notification_level = 2 WHERE id = 2"
end
def down
diff --git a/db/migrate/20170501191912_add_upload_id_to_theme_fields.rb b/db/migrate/20170501191912_add_upload_id_to_theme_fields.rb
index 3b3f204803f..d502244f9e3 100644
--- a/db/migrate/20170501191912_add_upload_id_to_theme_fields.rb
+++ b/db/migrate/20170501191912_add_upload_id_to_theme_fields.rb
@@ -2,7 +2,7 @@
class AddUploadIdToThemeFields < ActiveRecord::Migration[4.2]
def up
- remove_index :theme_fields, [:theme_id, :target, :name]
+ remove_index :theme_fields, %i[theme_id target name]
rename_column :theme_fields, :target, :target_id
# we need a throwaway column here to keep running
@@ -14,16 +14,19 @@ class AddUploadIdToThemeFields < ActiveRecord::Migration[4.2]
add_column :theme_fields, :upload_id, :integer
add_column :theme_fields, :type_id, :integer, null: false, default: 0
- add_index :theme_fields, [:theme_id, :target_id, :type_id, :name], unique: true, name: 'theme_field_unique_index'
+ add_index :theme_fields,
+ %i[theme_id target_id type_id name],
+ unique: true,
+ name: "theme_field_unique_index"
execute "UPDATE theme_fields SET type_id = 1 WHERE name IN ('scss', 'embedded_scss')"
end
def down
remove_column :theme_fields, :target
- execute 'drop index theme_field_unique_index'
+ execute "drop index theme_field_unique_index"
rename_column :theme_fields, :target_id, :target
remove_column :theme_fields, :upload_id
remove_column :theme_fields, :type_id
- add_index :theme_fields, [:theme_id, :target, :name], unique: true
+ add_index :theme_fields, %i[theme_id target name], unique: true
end
end
diff --git a/db/migrate/20170512185227_create_topic_status_updates_again.rb b/db/migrate/20170512185227_create_topic_status_updates_again.rb
index 48ab7e6a260..e95c7732f6e 100644
--- a/db/migrate/20170512185227_create_topic_status_updates_again.rb
+++ b/db/migrate/20170512185227_create_topic_status_updates_again.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'migration/table_dropper'
+require "migration/table_dropper"
class CreateTopicStatusUpdatesAgain < ActiveRecord::Migration[4.2]
def up
@@ -16,7 +16,7 @@ class CreateTopicStatusUpdatesAgain < ActiveRecord::Migration[4.2]
t.integer :category_id
end
- Migration::TableDropper.read_only_table('topic_status_updates')
+ Migration::TableDropper.read_only_table("topic_status_updates")
end
def down
diff --git a/db/migrate/20170628152322_create_watched_words.rb b/db/migrate/20170628152322_create_watched_words.rb
index 960f2de63b7..0c1e9efe2ce 100644
--- a/db/migrate/20170628152322_create_watched_words.rb
+++ b/db/migrate/20170628152322_create_watched_words.rb
@@ -3,11 +3,11 @@
class CreateWatchedWords < ActiveRecord::Migration[4.2]
def change
create_table :watched_words do |t|
- t.string :word, null: false
+ t.string :word, null: false
t.integer :action, null: false
t.timestamps null: false
end
- add_index :watched_words, [:action, :word], unique: true
+ add_index :watched_words, %i[action word], unique: true
end
end
diff --git a/db/migrate/20170703144855_add_visibility_level_to_groups.rb b/db/migrate/20170703144855_add_visibility_level_to_groups.rb
index 76fb138f63f..3deb97779fe 100644
--- a/db/migrate/20170703144855_add_visibility_level_to_groups.rb
+++ b/db/migrate/20170703144855_add_visibility_level_to_groups.rb
@@ -2,7 +2,6 @@
class AddVisibilityLevelToGroups < ActiveRecord::Migration[4.2]
def change
-
add_column :groups, :visibility_level, :integer, default: 0, null: false
execute <<~SQL
UPDATE groups
diff --git a/db/migrate/20170704142141_add_visible_back_to_groups.rb b/db/migrate/20170704142141_add_visible_back_to_groups.rb
index 84f25cb695a..e48d012dc14 100644
--- a/db/migrate/20170704142141_add_visible_back_to_groups.rb
+++ b/db/migrate/20170704142141_add_visible_back_to_groups.rb
@@ -4,6 +4,6 @@ class AddVisibleBackToGroups < ActiveRecord::Migration[4.2]
def change
# add the visible column so it is delay dropped this cleans up some deploy issues
add_column :groups, :visible, :boolean, default: true, null: false
- execute 'UPDATE groups set visible = false where visibility_level > 0'
+ execute "UPDATE groups set visible = false where visibility_level > 0"
end
end
diff --git a/db/migrate/20170713164357_create_search_logs.rb b/db/migrate/20170713164357_create_search_logs.rb
index 8fafc76c651..8d4fc6dec34 100644
--- a/db/migrate/20170713164357_create_search_logs.rb
+++ b/db/migrate/20170713164357_create_search_logs.rb
@@ -5,7 +5,7 @@ class CreateSearchLogs < ActiveRecord::Migration[4.2]
create_table :search_logs do |t|
t.string :term, null: false
t.integer :user_id, null: true
- t.inet :ip_address, null: false
+ t.inet :ip_address, null: false
t.integer :clicked_topic_id, null: true
t.integer :search_type, null: false
t.datetime :created_at, null: false
diff --git a/db/migrate/20170717084947_create_user_emails.rb b/db/migrate/20170717084947_create_user_emails.rb
index 3876893a695..e15a1f6aa46 100644
--- a/db/migrate/20170717084947_create_user_emails.rb
+++ b/db/migrate/20170717084947_create_user_emails.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'migration/column_dropper'
+require "migration/column_dropper"
class CreateUserEmails < ActiveRecord::Migration[4.2]
def up
@@ -12,7 +12,7 @@ class CreateUserEmails < ActiveRecord::Migration[4.2]
end
add_index :user_emails, :user_id
- add_index :user_emails, [:user_id, :primary], unique: true
+ add_index :user_emails, %i[user_id primary], unique: true
execute "CREATE UNIQUE INDEX index_user_emails_on_email ON user_emails (lower(email));"
diff --git a/db/migrate/20170818191909_split_alias_levels.rb b/db/migrate/20170818191909_split_alias_levels.rb
index 68c6ef041ca..e02c639df3a 100644
--- a/db/migrate/20170818191909_split_alias_levels.rb
+++ b/db/migrate/20170818191909_split_alias_levels.rb
@@ -5,7 +5,7 @@ class SplitAliasLevels < ActiveRecord::Migration[4.2]
add_column :groups, :messageable_level, :integer, default: 0
add_column :groups, :mentionable_level, :integer, default: 0
- execute 'UPDATE groups SET messageable_level = alias_level, mentionable_level = alias_level'
+ execute "UPDATE groups SET messageable_level = alias_level, mentionable_level = alias_level"
end
def down
diff --git a/db/migrate/20170823173427_create_tag_search_data.rb b/db/migrate/20170823173427_create_tag_search_data.rb
index 87db88bcfef..c43c4d8163d 100644
--- a/db/migrate/20170823173427_create_tag_search_data.rb
+++ b/db/migrate/20170823173427_create_tag_search_data.rb
@@ -4,15 +4,15 @@ class CreateTagSearchData < ActiveRecord::Migration[4.2]
def up
create_table :tag_search_data, primary_key: :tag_id do |t|
t.tsvector "search_data"
- t.text "raw_data"
- t.text "locale"
- t.integer "version", default: 0
+ t.text "raw_data"
+ t.text "locale"
+ t.integer "version", default: 0
end
- execute 'create index idx_search_tag on tag_search_data using gin(search_data)'
+ execute "create index idx_search_tag on tag_search_data using gin(search_data)"
end
def down
- execute 'drop index idx_search_tag'
+ execute "drop index idx_search_tag"
drop_table :tag_search_data
end
end
diff --git a/db/migrate/20170824172615_add_slug_index_on_topic.rb b/db/migrate/20170824172615_add_slug_index_on_topic.rb
index f033b1e5aba..92592b69ca5 100644
--- a/db/migrate/20170824172615_add_slug_index_on_topic.rb
+++ b/db/migrate/20170824172615_add_slug_index_on_topic.rb
@@ -2,10 +2,10 @@
class AddSlugIndexOnTopic < ActiveRecord::Migration[4.2]
def up
- execute 'CREATE INDEX idxTopicSlug ON topics(slug) WHERE deleted_at IS NULL AND slug IS NOT NULL'
+ execute "CREATE INDEX idxTopicSlug ON topics(slug) WHERE deleted_at IS NULL AND slug IS NOT NULL"
end
def down
- execute 'DROP INDEX idxTopicSlug'
+ execute "DROP INDEX idxTopicSlug"
end
end
diff --git a/db/migrate/20171110174413_rename_blocked_silence.rb b/db/migrate/20171110174413_rename_blocked_silence.rb
index d1185096554..7338259848e 100644
--- a/db/migrate/20171110174413_rename_blocked_silence.rb
+++ b/db/migrate/20171110174413_rename_blocked_silence.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
class RenameBlockedSilence < ActiveRecord::Migration[5.1]
-
def setting(old, new)
execute "UPDATE site_settings SET name='#{new}' where name='#{old}'"
end
diff --git a/db/migrate/20171113214725_add_time_read_to_user_visits.rb b/db/migrate/20171113214725_add_time_read_to_user_visits.rb
index ef3bd037bc2..3359f2323db 100644
--- a/db/migrate/20171113214725_add_time_read_to_user_visits.rb
+++ b/db/migrate/20171113214725_add_time_read_to_user_visits.rb
@@ -3,11 +3,11 @@
class AddTimeReadToUserVisits < ActiveRecord::Migration[5.1]
def up
add_column :user_visits, :time_read, :integer, null: false, default: 0 # in seconds
- add_index :user_visits, [:user_id, :visited_at, :time_read]
+ add_index :user_visits, %i[user_id visited_at time_read]
end
def down
- remove_index :user_visits, [:user_id, :visited_at, :time_read]
+ remove_index :user_visits, %i[user_id visited_at time_read]
remove_column :user_visits, :time_read
end
end
diff --git a/db/migrate/20171220181249_change_user_emails_primary_index.rb b/db/migrate/20171220181249_change_user_emails_primary_index.rb
index 2c1187f7da6..dc9863e39e4 100644
--- a/db/migrate/20171220181249_change_user_emails_primary_index.rb
+++ b/db/migrate/20171220181249_change_user_emails_primary_index.rb
@@ -2,12 +2,12 @@
class ChangeUserEmailsPrimaryIndex < ActiveRecord::Migration[5.1]
def up
- remove_index :user_emails, [:user_id, :primary]
- add_index :user_emails, [:user_id, :primary], unique: true, where: '"primary"'
+ remove_index :user_emails, %i[user_id primary]
+ add_index :user_emails, %i[user_id primary], unique: true, where: '"primary"'
end
def down
- remove_index :user_emails, [:user_id, :primary]
- add_index :user_emails, [:user_id, :primary], unique: true
+ remove_index :user_emails, %i[user_id primary]
+ add_index :user_emails, %i[user_id primary], unique: true
end
end
diff --git a/db/migrate/20180131052859_rename_private_personal.rb b/db/migrate/20180131052859_rename_private_personal.rb
index d475f33a99e..1952bf5854b 100644
--- a/db/migrate/20180131052859_rename_private_personal.rb
+++ b/db/migrate/20180131052859_rename_private_personal.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
class RenamePrivatePersonal < ActiveRecord::Migration[5.1]
-
def setting(old, new)
execute "UPDATE site_settings SET name='#{new}' where name='#{old}'"
end
diff --git a/db/migrate/20180207163946_create_category_tag_stats.rb b/db/migrate/20180207163946_create_category_tag_stats.rb
index 71682505731..b5560a58313 100644
--- a/db/migrate/20180207163946_create_category_tag_stats.rb
+++ b/db/migrate/20180207163946_create_category_tag_stats.rb
@@ -8,7 +8,7 @@ class CreateCategoryTagStats < ActiveRecord::Migration[5.1]
t.integer :topic_count, default: 0, null: false
end
- add_index :category_tag_stats, [:category_id, :topic_count]
- add_index :category_tag_stats, [:category_id, :tag_id], unique: true
+ add_index :category_tag_stats, %i[category_id topic_count]
+ add_index :category_tag_stats, %i[category_id tag_id], unique: true
end
end
diff --git a/db/migrate/20180308071922_drop_raise_read_only_function.rb b/db/migrate/20180308071922_drop_raise_read_only_function.rb
index 1f303e7c157..39bdf14e475 100644
--- a/db/migrate/20180308071922_drop_raise_read_only_function.rb
+++ b/db/migrate/20180308071922_drop_raise_read_only_function.rb
@@ -2,9 +2,7 @@
class DropRaiseReadOnlyFunction < ActiveRecord::Migration[5.1]
def up
- DB.exec(
- "DROP FUNCTION IF EXISTS raise_read_only() CASCADE;"
- )
+ DB.exec("DROP FUNCTION IF EXISTS raise_read_only() CASCADE;")
end
def down
diff --git a/db/migrate/20180320190339_create_web_crawler_requests.rb b/db/migrate/20180320190339_create_web_crawler_requests.rb
index 291e4fbf75a..21b667e61df 100644
--- a/db/migrate/20180320190339_create_web_crawler_requests.rb
+++ b/db/migrate/20180320190339_create_web_crawler_requests.rb
@@ -8,6 +8,6 @@ class CreateWebCrawlerRequests < ActiveRecord::Migration[5.1]
t.integer :count, null: false, default: 0
end
- add_index :web_crawler_requests, [:date, :user_agent], unique: true
+ add_index :web_crawler_requests, %i[date user_agent], unique: true
end
end
diff --git a/db/migrate/20180323154826_create_tag_group_permissions.rb b/db/migrate/20180323154826_create_tag_group_permissions.rb
index 57bf1a018ad..d12721c7891 100644
--- a/db/migrate/20180323154826_create_tag_group_permissions.rb
+++ b/db/migrate/20180323154826_create_tag_group_permissions.rb
@@ -3,7 +3,7 @@
class CreateTagGroupPermissions < ActiveRecord::Migration[5.1]
def change
create_table :tag_group_permissions do |t|
- t.references :tag_group, null: false
+ t.references :tag_group, null: false
t.references :group, null: false
t.integer :permission_type, default: 1, null: false
t.timestamps null: false
diff --git a/db/migrate/20180327062911_add_post_custom_fields_akismet_index.rb b/db/migrate/20180327062911_add_post_custom_fields_akismet_index.rb
index fd7920b0671..68b1483bcef 100644
--- a/db/migrate/20180327062911_add_post_custom_fields_akismet_index.rb
+++ b/db/migrate/20180327062911_add_post_custom_fields_akismet_index.rb
@@ -7,8 +7,9 @@
class AddPostCustomFieldsAkismetIndex < ActiveRecord::Migration[5.1]
def change
- add_index :post_custom_fields, [:post_id],
- name: 'idx_post_custom_fields_akismet',
- where: "name = 'AKISMET_STATE' AND value = 'needs_review'"
+ add_index :post_custom_fields,
+ [:post_id],
+ name: "idx_post_custom_fields_akismet",
+ where: "name = 'AKISMET_STATE' AND value = 'needs_review'"
end
end
diff --git a/db/migrate/20180420141134_remove_staff_tags_setting.rb b/db/migrate/20180420141134_remove_staff_tags_setting.rb
index cf7300a2047..eba9cc41aa5 100644
--- a/db/migrate/20180420141134_remove_staff_tags_setting.rb
+++ b/db/migrate/20180420141134_remove_staff_tags_setting.rb
@@ -12,14 +12,15 @@ class RemoveStaffTagsSetting < ActiveRecord::Migration[5.1]
result = execute("SELECT value FROM site_settings WHERE name = 'staff_tags'").to_a
if result.length > 0
- if tags = result[0]['value']&.split('|')
- tag_group = execute(
- "INSERT INTO tag_groups (name, created_at, updated_at)
+ if tags = result[0]["value"]&.split("|")
+ tag_group =
+ execute(
+ "INSERT INTO tag_groups (name, created_at, updated_at)
VALUES ('staff tags', now(), now())
- RETURNING id"
- )
+ RETURNING id",
+ )
- tag_group_id = tag_group[0]['id']
+ tag_group_id = tag_group[0]["id"]
execute(
"INSERT INTO tag_group_permissions
@@ -28,17 +29,17 @@ class RemoveStaffTagsSetting < ActiveRecord::Migration[5.1]
(#{tag_group_id}, #{Group::AUTO_GROUPS[:everyone]},
#{TagGroupPermission.permission_types[:readonly]}, now(), now()),
(#{tag_group_id}, #{Group::AUTO_GROUPS[:staff]},
- #{TagGroupPermission.permission_types[:full]}, now(), now())"
+ #{TagGroupPermission.permission_types[:full]}, now(), now())",
)
tags.each do |tag_name|
tag = execute("SELECT id FROM tags WHERE name = '#{tag_name}'").to_a
- if tag[0] && tag[0]['id']
+ if tag[0] && tag[0]["id"]
execute(
"INSERT INTO tag_group_memberships
(tag_id, tag_group_id, created_at, updated_at)
VALUES
- (#{tag[0]['id']}, #{tag_group_id}, now(), now())"
+ (#{tag[0]["id"]}, #{tag_group_id}, now(), now())",
)
end
end
diff --git a/db/migrate/20180521175611_change_indexes_topic_view_item.rb b/db/migrate/20180521175611_change_indexes_topic_view_item.rb
index bd125ed15d7..60d70a45769 100644
--- a/db/migrate/20180521175611_change_indexes_topic_view_item.rb
+++ b/db/migrate/20180521175611_change_indexes_topic_view_item.rb
@@ -3,14 +3,14 @@
class ChangeIndexesTopicViewItem < ActiveRecord::Migration[5.1]
def up
remove_index :topic_views,
- column: [:ip_address, :topic_id],
- name: :ip_address_topic_id_topic_views,
- unique: true
+ column: %i[ip_address topic_id],
+ name: :ip_address_topic_id_topic_views,
+ unique: true
remove_index :topic_views,
- column: [:user_id, :topic_id],
- name: :user_id_topic_id_topic_views,
- unique: true
+ column: %i[user_id topic_id],
+ name: :user_id_topic_id_topic_views,
+ unique: true
end
def down
diff --git a/db/migrate/20180521191418_allow_null_ip_user_profile_view.rb b/db/migrate/20180521191418_allow_null_ip_user_profile_view.rb
index c7bdb05a166..a45e882ed39 100644
--- a/db/migrate/20180521191418_allow_null_ip_user_profile_view.rb
+++ b/db/migrate/20180521191418_allow_null_ip_user_profile_view.rb
@@ -10,16 +10,17 @@ class AllowNullIpUserProfileView < ActiveRecord::Migration[5.1]
end
remove_index :user_profile_views,
- column: [:viewed_at, :ip_address, :user_profile_id],
- name: :unique_profile_view_ip,
- unique: true
+ column: %i[viewed_at ip_address user_profile_id],
+ name: :unique_profile_view_ip,
+ unique: true
remove_index :user_profile_views,
- column: [:viewed_at, :user_id, :user_profile_id],
- name: :unique_profile_view_user,
- unique: true
- add_index :user_profile_views, [:viewed_at, :user_id, :ip_address, :user_profile_id],
- name: :unique_profile_view_user_or_ip,
- unique: true
+ column: %i[viewed_at user_id user_profile_id],
+ name: :unique_profile_view_user,
+ unique: true
+ add_index :user_profile_views,
+ %i[viewed_at user_id ip_address user_profile_id],
+ name: :unique_profile_view_user_or_ip,
+ unique: true
end
def down
diff --git a/db/migrate/20180621013807_add_index_topic_id_percent_rank_on_posts.rb b/db/migrate/20180621013807_add_index_topic_id_percent_rank_on_posts.rb
index aaacaa0846f..a1467e15e97 100644
--- a/db/migrate/20180621013807_add_index_topic_id_percent_rank_on_posts.rb
+++ b/db/migrate/20180621013807_add_index_topic_id_percent_rank_on_posts.rb
@@ -2,10 +2,10 @@
class AddIndexTopicIdPercentRankOnPosts < ActiveRecord::Migration[5.2]
def up
- add_index :posts, [:topic_id, :percent_rank], order: { percent_rank: :asc }
+ add_index :posts, %i[topic_id percent_rank], order: { percent_rank: :asc }
end
def down
- remove_index :posts, [:topic_id, :percent_rank]
+ remove_index :posts, %i[topic_id percent_rank]
end
end
diff --git a/db/migrate/20180706054922_drop_key_column_from_themes.rb b/db/migrate/20180706054922_drop_key_column_from_themes.rb
index 3df4da749d9..8027a2d7bd0 100644
--- a/db/migrate/20180706054922_drop_key_column_from_themes.rb
+++ b/db/migrate/20180706054922_drop_key_column_from_themes.rb
@@ -2,7 +2,7 @@
class DropKeyColumnFromThemes < ActiveRecord::Migration[5.2]
def up
- add_column :user_options, :theme_ids, :integer, array: true, null: false, default: []
+ add_column :user_options, :theme_ids, :integer, array: true, null: false, default: []
execute(
"UPDATE user_options AS uo
@@ -12,14 +12,14 @@ class DropKeyColumnFromThemes < ActiveRecord::Migration[5.2]
INNER JOIN user_options
ON themes.key = user_options.theme_key
WHERE user_options.user_id = uo.user_id
- ) WHERE uo.theme_key IN (SELECT key FROM themes)"
+ ) WHERE uo.theme_key IN (SELECT key FROM themes)",
)
execute(
"INSERT INTO site_settings (name, data_type, value, created_at, updated_at)
SELECT 'default_theme_id', 3, id, now(), now()
FROM themes
- WHERE key = (SELECT value FROM site_settings WHERE name = 'default_theme_key')"
+ WHERE key = (SELECT value FROM site_settings WHERE name = 'default_theme_key')",
)
execute("DELETE FROM site_settings WHERE name = 'default_theme_key'")
diff --git a/db/migrate/20180710075119_add_index_topic_id_sort_order_on_posts.rb b/db/migrate/20180710075119_add_index_topic_id_sort_order_on_posts.rb
index 90baa4d673b..083d7215804 100644
--- a/db/migrate/20180710075119_add_index_topic_id_sort_order_on_posts.rb
+++ b/db/migrate/20180710075119_add_index_topic_id_sort_order_on_posts.rb
@@ -2,6 +2,6 @@
class AddIndexTopicIdSortOrderOnPosts < ActiveRecord::Migration[5.2]
def change
- add_index :posts, [:topic_id, :sort_order], order: { sort_order: :asc }
+ add_index :posts, %i[topic_id sort_order], order: { sort_order: :asc }
end
end
diff --git a/db/migrate/20180710172959_disallow_multi_levels_theme_components.rb b/db/migrate/20180710172959_disallow_multi_levels_theme_components.rb
index ee672de5c0c..99caa7e55e4 100644
--- a/db/migrate/20180710172959_disallow_multi_levels_theme_components.rb
+++ b/db/migrate/20180710172959_disallow_multi_levels_theme_components.rb
@@ -3,34 +3,44 @@
class DisallowMultiLevelsThemeComponents < ActiveRecord::Migration[5.2]
def up
@handled = []
- top_parents = DB.query("
+ top_parents =
+ DB.query(
+ "
SELECT parent_theme_id, child_theme_id
FROM child_themes
WHERE parent_theme_id NOT IN (SELECT child_theme_id FROM child_themes)
- ")
+ ",
+ )
- top_parents.each do |top_parent|
- migrate_child(top_parent, top_parent)
- end
+ top_parents.each { |top_parent| migrate_child(top_parent, top_parent) }
if @handled.size > 0
- execute("
+ execute(
+ "
DELETE FROM child_themes
WHERE parent_theme_id NOT IN (#{top_parents.map(&:parent_theme_id).join(", ")})
- ")
+ ",
+ )
end
- execute("
+ execute(
+ "
UPDATE themes
SET user_selectable = false
FROM child_themes
WHERE themes.id = child_themes.child_theme_id
AND themes.user_selectable = true
- ")
+ ",
+ )
- default = DB.query_single("SELECT value FROM site_settings WHERE name = 'default_theme_id'").first
+ default =
+ DB.query_single("SELECT value FROM site_settings WHERE name = 'default_theme_id'").first
if default
- default_child = DB.query("SELECT 1 AS one FROM child_themes WHERE child_theme_id = ?", default.to_i).present?
+ default_child =
+ DB.query(
+ "SELECT 1 AS one FROM child_themes WHERE child_theme_id = ?",
+ default.to_i,
+ ).present?
execute("DELETE FROM site_settings WHERE name = 'default_theme_id'") if default_child
end
end
@@ -43,28 +53,39 @@ class DisallowMultiLevelsThemeComponents < ActiveRecord::Migration[5.2]
def migrate_child(parent, top_parent)
unless already_exists?(top_parent.parent_theme_id, parent.child_theme_id)
- execute("
+ execute(
+ "
INSERT INTO child_themes (parent_theme_id, child_theme_id, created_at, updated_at)
VALUES (#{top_parent.parent_theme_id}, #{parent.child_theme_id}, now(), now())
- ")
+ ",
+ )
end
@handled << [top_parent.parent_theme_id, parent.parent_theme_id, parent.child_theme_id]
- children = DB.query("
+ children =
+ DB.query(
+ "
SELECT parent_theme_id, child_theme_id
FROM child_themes
- WHERE parent_theme_id = :child", child: parent.child_theme_id
- )
+ WHERE parent_theme_id = :child",
+ child: parent.child_theme_id,
+ )
children.each do |child|
- unless @handled.include?([top_parent.parent_theme_id, child.parent_theme_id, child.child_theme_id])
+ unless @handled.include?(
+ [top_parent.parent_theme_id, child.parent_theme_id, child.child_theme_id],
+ )
migrate_child(child, top_parent)
end
end
end
def already_exists?(parent, child)
- DB.query("SELECT 1 AS one FROM child_themes WHERE child_theme_id = :child AND parent_theme_id = :parent", child: child, parent: parent).present?
+ DB.query(
+ "SELECT 1 AS one FROM child_themes WHERE child_theme_id = :child AND parent_theme_id = :parent",
+ child: child,
+ parent: parent,
+ ).present?
end
end
diff --git a/db/migrate/20180716072125_alter_bounce_key_on_email_logs.rb b/db/migrate/20180716072125_alter_bounce_key_on_email_logs.rb
index 736c0074a53..8ebef173ee6 100644
--- a/db/migrate/20180716072125_alter_bounce_key_on_email_logs.rb
+++ b/db/migrate/20180716072125_alter_bounce_key_on_email_logs.rb
@@ -2,7 +2,7 @@
class AlterBounceKeyOnEmailLogs < ActiveRecord::Migration[5.2]
def up
- change_column :email_logs, :bounce_key, 'uuid USING bounce_key::uuid'
+ change_column :email_logs, :bounce_key, "uuid USING bounce_key::uuid"
end
def down
diff --git a/db/migrate/20180716140323_add_uniq_ip_or_user_id_topic_views.rb b/db/migrate/20180716140323_add_uniq_ip_or_user_id_topic_views.rb
index 7bb452f01fb..0462da362af 100644
--- a/db/migrate/20180716140323_add_uniq_ip_or_user_id_topic_views.rb
+++ b/db/migrate/20180716140323_add_uniq_ip_or_user_id_topic_views.rb
@@ -4,14 +4,16 @@ class AddUniqIpOrUserIdTopicViews < ActiveRecord::Migration[5.2]
disable_ddl_transaction!
def change
- unless index_exists?(:topic_views, [:user_id, :ip_address, :topic_id],
- name: :uniq_ip_or_user_id_topic_views
- )
-
- add_index :topic_views, [:user_id, :ip_address, :topic_id],
- name: :uniq_ip_or_user_id_topic_views,
- unique: true,
- algorithm: :concurrently
+ unless index_exists?(
+ :topic_views,
+ %i[user_id ip_address topic_id],
+ name: :uniq_ip_or_user_id_topic_views,
+ )
+ add_index :topic_views,
+ %i[user_id ip_address topic_id],
+ name: :uniq_ip_or_user_id_topic_views,
+ unique: true,
+ algorithm: :concurrently
end
end
end
diff --git a/db/migrate/20180717084758_alter_reply_key_on_email_logs.rb b/db/migrate/20180717084758_alter_reply_key_on_email_logs.rb
index 26dd91944fb..fe9ef02f65f 100644
--- a/db/migrate/20180717084758_alter_reply_key_on_email_logs.rb
+++ b/db/migrate/20180717084758_alter_reply_key_on_email_logs.rb
@@ -2,7 +2,7 @@
class AlterReplyKeyOnEmailLogs < ActiveRecord::Migration[5.2]
def up
- change_column :email_logs, :reply_key, 'uuid USING reply_key::uuid'
+ change_column :email_logs, :reply_key, "uuid USING reply_key::uuid"
end
def down
diff --git a/db/migrate/20180718062728_create_post_reply_keys.rb b/db/migrate/20180718062728_create_post_reply_keys.rb
index ddc622175b6..92e64e64f61 100644
--- a/db/migrate/20180718062728_create_post_reply_keys.rb
+++ b/db/migrate/20180718062728_create_post_reply_keys.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'migration/column_dropper'
+require "migration/column_dropper"
class CreatePostReplyKeys < ActiveRecord::Migration[5.2]
def up
@@ -46,7 +46,7 @@ class CreatePostReplyKeys < ActiveRecord::Migration[5.2]
execute(sql)
- add_index :post_reply_keys, [:user_id, :post_id], unique: true
+ add_index :post_reply_keys, %i[user_id post_id], unique: true
end
def down
diff --git a/db/migrate/20180719103905_alter_indexes_on_email_logs.rb b/db/migrate/20180719103905_alter_indexes_on_email_logs.rb
index 4633de0dcac..15a4f0fbe41 100644
--- a/db/migrate/20180719103905_alter_indexes_on_email_logs.rb
+++ b/db/migrate/20180719103905_alter_indexes_on_email_logs.rb
@@ -3,12 +3,12 @@
class AlterIndexesOnEmailLogs < ActiveRecord::Migration[5.2]
def change
remove_index :email_logs,
- name: "index_email_logs_on_user_id_and_created_at",
- column: [:user_id, :created_at]
+ name: "index_email_logs_on_user_id_and_created_at",
+ column: %i[user_id created_at]
add_index :email_logs, :user_id
- remove_index :email_logs, [:skipped, :created_at]
- add_index :email_logs, [:skipped, :bounced, :created_at]
+ remove_index :email_logs, %i[skipped created_at]
+ add_index :email_logs, %i[skipped bounced created_at]
end
end
diff --git a/db/migrate/20180720054856_create_skipped_email_logs.rb b/db/migrate/20180720054856_create_skipped_email_logs.rb
index 78cfe6c77ce..0b20e08504d 100644
--- a/db/migrate/20180720054856_create_skipped_email_logs.rb
+++ b/db/migrate/20180720054856_create_skipped_email_logs.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'migration/column_dropper'
+require "migration/column_dropper"
class CreateSkippedEmailLogs < ActiveRecord::Migration[5.2]
def change
@@ -44,6 +44,6 @@ class CreateSkippedEmailLogs < ActiveRecord::Migration[5.2]
execute(sql)
- Migration::ColumnDropper.mark_readonly('email_logs', 'skipped_reason')
+ Migration::ColumnDropper.mark_readonly("email_logs", "skipped_reason")
end
end
diff --git a/db/migrate/20180727042448_drop_reply_key_skipped_skipped_reason_from_email_logs.rb b/db/migrate/20180727042448_drop_reply_key_skipped_skipped_reason_from_email_logs.rb
index 9e957441802..c0983714c36 100644
--- a/db/migrate/20180727042448_drop_reply_key_skipped_skipped_reason_from_email_logs.rb
+++ b/db/migrate/20180727042448_drop_reply_key_skipped_skipped_reason_from_email_logs.rb
@@ -2,9 +2,9 @@
class DropReplyKeySkippedSkippedReasonFromEmailLogs < ActiveRecord::Migration[5.2]
def up
- remove_index :email_logs, [:skipped, :bounced, :created_at]
- remove_index :email_logs, name: 'idx_email_logs_user_created_filtered'
- add_index :email_logs, [:user_id, :created_at]
+ remove_index :email_logs, %i[skipped bounced created_at]
+ remove_index :email_logs, name: "idx_email_logs_user_created_filtered"
+ add_index :email_logs, %i[user_id created_at]
end
def down
diff --git a/db/migrate/20180803085321_add_index_email_logs_on_bounced.rb b/db/migrate/20180803085321_add_index_email_logs_on_bounced.rb
index d0b640a4303..7fb3ed5251d 100644
--- a/db/migrate/20180803085321_add_index_email_logs_on_bounced.rb
+++ b/db/migrate/20180803085321_add_index_email_logs_on_bounced.rb
@@ -3,6 +3,6 @@
class AddIndexEmailLogsOnBounced < ActiveRecord::Migration[5.2]
def change
add_index :email_logs, :bounced
- remove_index :email_logs, [:user_id, :created_at]
+ remove_index :email_logs, %i[user_id created_at]
end
end
diff --git a/db/migrate/20180812150839_add_user_api_keys_last_used_at.rb b/db/migrate/20180812150839_add_user_api_keys_last_used_at.rb
index 09cd56971a1..0203582f954 100644
--- a/db/migrate/20180812150839_add_user_api_keys_last_used_at.rb
+++ b/db/migrate/20180812150839_add_user_api_keys_last_used_at.rb
@@ -2,6 +2,10 @@
class AddUserApiKeysLastUsedAt < ActiveRecord::Migration[5.2]
def change
- add_column :user_api_keys, :last_used_at, :datetime, null: false, default: -> { 'CURRENT_TIMESTAMP' }
+ add_column :user_api_keys,
+ :last_used_at,
+ :datetime,
+ null: false,
+ default: -> { "CURRENT_TIMESTAMP" }
end
end
diff --git a/db/migrate/20180813074843_add_component_to_themes.rb b/db/migrate/20180813074843_add_component_to_themes.rb
index 9bd08859c0a..6f7a68104ba 100644
--- a/db/migrate/20180813074843_add_component_to_themes.rb
+++ b/db/migrate/20180813074843_add_component_to_themes.rb
@@ -4,22 +4,28 @@ class AddComponentToThemes < ActiveRecord::Migration[5.2]
def up
add_column :themes, :component, :boolean, null: false, default: false
- execute("
+ execute(
+ "
UPDATE themes
SET component = true, color_scheme_id = NULL, user_selectable = false
WHERE id IN (SELECT child_theme_id FROM child_themes)
- ")
+ ",
+ )
- execute("
+ execute(
+ "
UPDATE site_settings
SET value = -1
WHERE name = 'default_theme_id' AND value::integer IN (SELECT id FROM themes WHERE component)
- ")
+ ",
+ )
- execute("
+ execute(
+ "
DELETE FROM child_themes
WHERE parent_theme_id IN (SELECT id FROM themes WHERE component)
- ")
+ ",
+ )
end
def down
diff --git a/db/migrate/20180917024729_remove_superfluous_columns.rb b/db/migrate/20180917024729_remove_superfluous_columns.rb
index a2307345d0a..cc2f87a31de 100644
--- a/db/migrate/20180917024729_remove_superfluous_columns.rb
+++ b/db/migrate/20180917024729_remove_superfluous_columns.rb
@@ -1,80 +1,63 @@
# frozen_string_literal: true
-require 'migration/column_dropper'
-require 'badge_posts_view_manager'
+require "migration/column_dropper"
+require "badge_posts_view_manager"
class RemoveSuperfluousColumns < ActiveRecord::Migration[5.2]
DROPPED_COLUMNS ||= {
- user_profiles: %i{
- card_image_badge_id
- },
- categories: %i{
- logo_url
- background_url
- suppress_from_homepage
- },
- groups: %i{
- visible
- public
- alias_level
- },
- theme_fields: %i{target},
- user_stats: %i{first_topic_unread_at},
- topics: %i{
- auto_close_at
- auto_close_user_id
- auto_close_started_at
- auto_close_based_on_last_post
- auto_close_hours
- inappropriate_count
- bookmark_count
- off_topic_count
- illegal_count
- notify_user_count
- last_unread_at
- vote_count
- },
- users: %i{
- email
- email_always
- mailing_list_mode
- email_digests
- email_direct
- email_private_messages
- external_links_in_new_tab
- enable_quoting
- dynamic_favicon
- disable_jump_reply
- edit_history_public
- automatically_unpin_topics
- digest_after_days
- auto_track_topics_after_msecs
- new_topic_duration_minutes
- last_redirected_to_top_at
- auth_token
- auth_token_updated_at
- blocked
- silenced
- trust_level_locked
- },
- user_auth_tokens: %i{legacy},
- user_options: %i{theme_key},
- themes: %i{key},
- email_logs: %i{
- topic_id
- reply_key
- skipped
- skipped_reason
- },
- posts: %i{vote_count}
+ user_profiles: %i[card_image_badge_id],
+ categories: %i[logo_url background_url suppress_from_homepage],
+ groups: %i[visible public alias_level],
+ theme_fields: %i[target],
+ user_stats: %i[first_topic_unread_at],
+ topics: %i[
+ auto_close_at
+ auto_close_user_id
+ auto_close_started_at
+ auto_close_based_on_last_post
+ auto_close_hours
+ inappropriate_count
+ bookmark_count
+ off_topic_count
+ illegal_count
+ notify_user_count
+ last_unread_at
+ vote_count
+ ],
+ users: %i[
+ email
+ email_always
+ mailing_list_mode
+ email_digests
+ email_direct
+ email_private_messages
+ external_links_in_new_tab
+ enable_quoting
+ dynamic_favicon
+ disable_jump_reply
+ edit_history_public
+ automatically_unpin_topics
+ digest_after_days
+ auto_track_topics_after_msecs
+ new_topic_duration_minutes
+ last_redirected_to_top_at
+ auth_token
+ auth_token_updated_at
+ blocked
+ silenced
+ trust_level_locked
+ ],
+ user_auth_tokens: %i[legacy],
+ user_options: %i[theme_key],
+ themes: %i[key],
+ email_logs: %i[topic_id reply_key skipped skipped_reason],
+ posts: %i[vote_count],
}
def up
BadgePostsViewManager.drop!
- DROPPED_COLUMNS.each do |table, columns|
- Migration::ColumnDropper.execute_drop(table, columns)
- end
+ DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }
DB.exec "DROP FUNCTION IF EXISTS first_unread_topic_for(int)"
diff --git a/db/migrate/20180917034056_remove_superfluous_tables.rb b/db/migrate/20180917034056_remove_superfluous_tables.rb
index f6524526835..5dfcb8ce95d 100644
--- a/db/migrate/20180917034056_remove_superfluous_tables.rb
+++ b/db/migrate/20180917034056_remove_superfluous_tables.rb
@@ -1,18 +1,12 @@
# frozen_string_literal: true
-require 'migration/table_dropper'
+require "migration/table_dropper"
class RemoveSuperfluousTables < ActiveRecord::Migration[5.2]
- DROPPED_TABLES ||= %i{
- category_featured_users
- versions
- topic_status_updates
- }
+ DROPPED_TABLES ||= %i[category_featured_users versions topic_status_updates]
def up
- DROPPED_TABLES.each do |table|
- Migration::TableDropper.execute_drop(table)
- end
+ DROPPED_TABLES.each { |table| Migration::TableDropper.execute_drop(table) }
end
def down
diff --git a/db/migrate/20180920042415_create_user_uploads.rb b/db/migrate/20180920042415_create_user_uploads.rb
index 5e592d00fc1..5481d67c416 100644
--- a/db/migrate/20180920042415_create_user_uploads.rb
+++ b/db/migrate/20180920042415_create_user_uploads.rb
@@ -8,7 +8,7 @@ class CreateUserUploads < ActiveRecord::Migration[5.2]
t.datetime :created_at, null: false
end
- add_index :user_uploads, [:upload_id, :user_id], unique: true
+ add_index :user_uploads, %i[upload_id user_id], unique: true
execute <<~SQL
INSERT INTO user_uploads(upload_id, user_id, created_at)
diff --git a/db/migrate/20180928105835_add_index_to_tags.rb b/db/migrate/20180928105835_add_index_to_tags.rb
index b964a330957..54a3ab0702c 100644
--- a/db/migrate/20180928105835_add_index_to_tags.rb
+++ b/db/migrate/20180928105835_add_index_to_tags.rb
@@ -11,7 +11,7 @@ class AddIndexToTags < ActiveRecord::Migration[5.2]
WHERE EXISTS(SELECT * FROM tags t WHERE lower(t.name) = lower(tags.name) AND t.id < tags.id)
SQL
- add_index :tags, 'lower(name)', unique: true
+ add_index :tags, "lower(name)", unique: true
end
def down
raise ActiveRecord::IrreversibleMigration
diff --git a/db/migrate/20181012123001_drop_group_locked_trust_level_from_user.rb b/db/migrate/20181012123001_drop_group_locked_trust_level_from_user.rb
index 3b3bd6eba30..5084d9c9048 100644
--- a/db/migrate/20181012123001_drop_group_locked_trust_level_from_user.rb
+++ b/db/migrate/20181012123001_drop_group_locked_trust_level_from_user.rb
@@ -1,16 +1,12 @@
# frozen_string_literal: true
-require 'migration/column_dropper'
+require "migration/column_dropper"
class DropGroupLockedTrustLevelFromUser < ActiveRecord::Migration[5.2]
- DROPPED_COLUMNS ||= {
- posts: %i{group_locked_trust_level}
- }
+ DROPPED_COLUMNS ||= { posts: %i[group_locked_trust_level] }
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
diff --git a/db/migrate/20181031165343_add_flag_stats_to_user.rb b/db/migrate/20181031165343_add_flag_stats_to_user.rb
index 22c5cb5f761..fa60e609557 100644
--- a/db/migrate/20181031165343_add_flag_stats_to_user.rb
+++ b/db/migrate/20181031165343_add_flag_stats_to_user.rb
@@ -18,7 +18,7 @@ class AddFlagStatsToUser < ActiveRecord::Migration[5.2]
SUM(CASE WHEN pa.deferred_at IS NOT NULL THEN 1 ELSE 0 END) as flags_ignored
FROM post_actions AS pa
INNER JOIN users AS u ON u.id = pa.user_id
- WHERE pa.post_action_type_id IN (#{PostActionType.notify_flag_types.values.join(', ')})
+ WHERE pa.post_action_type_id IN (#{PostActionType.notify_flag_types.values.join(", ")})
AND pa.user_id > 0
GROUP BY u.id
) AS x
diff --git a/db/migrate/20181108115009_create_user_associated_accounts.rb b/db/migrate/20181108115009_create_user_associated_accounts.rb
index 6dd4e00d803..5057096ff82 100644
--- a/db/migrate/20181108115009_create_user_associated_accounts.rb
+++ b/db/migrate/20181108115009_create_user_associated_accounts.rb
@@ -14,7 +14,13 @@ class CreateUserAssociatedAccounts < ActiveRecord::Migration[5.2]
t.timestamps
end
- add_index :user_associated_accounts, [:provider_name, :provider_uid], unique: true, name: 'associated_accounts_provider_uid'
- add_index :user_associated_accounts, [:provider_name, :user_id], unique: true, name: 'associated_accounts_provider_user'
+ add_index :user_associated_accounts,
+ %i[provider_name provider_uid],
+ unique: true,
+ name: "associated_accounts_provider_uid"
+ add_index :user_associated_accounts,
+ %i[provider_name user_id],
+ unique: true,
+ name: "associated_accounts_provider_user"
end
end
diff --git a/db/migrate/20181204193426_create_join_table_web_hooks_tags.rb b/db/migrate/20181204193426_create_join_table_web_hooks_tags.rb
index c6c34b6d635..89fc78c6447 100644
--- a/db/migrate/20181204193426_create_join_table_web_hooks_tags.rb
+++ b/db/migrate/20181204193426_create_join_table_web_hooks_tags.rb
@@ -3,7 +3,7 @@
class CreateJoinTableWebHooksTags < ActiveRecord::Migration[5.2]
def change
create_join_table :web_hooks, :tags do |t|
- t.index [:web_hook_id, :tag_id], name: 'web_hooks_tags', unique: true
+ t.index %i[web_hook_id tag_id], name: "web_hooks_tags", unique: true
end
end
end
diff --git a/db/migrate/20181220115844_add_smtp_and_imap_to_groups.rb b/db/migrate/20181220115844_add_smtp_and_imap_to_groups.rb
index 42f79a4b52e..7c4cdf4f743 100644
--- a/db/migrate/20181220115844_add_smtp_and_imap_to_groups.rb
+++ b/db/migrate/20181220115844_add_smtp_and_imap_to_groups.rb
@@ -10,7 +10,7 @@ class AddSmtpAndImapToGroups < ActiveRecord::Migration[5.2]
add_column :groups, :imap_port, :integer
add_column :groups, :imap_ssl, :boolean
- add_column :groups, :imap_mailbox_name, :string, default: '', null: false
+ add_column :groups, :imap_mailbox_name, :string, default: "", null: false
add_column :groups, :imap_uid_validity, :integer, default: 0, null: false
add_column :groups, :imap_last_uid, :integer, default: 0, null: false
diff --git a/db/migrate/20181221121805_create_theme_translation_override.rb b/db/migrate/20181221121805_create_theme_translation_override.rb
index bcf41901724..65ca084c993 100644
--- a/db/migrate/20181221121805_create_theme_translation_override.rb
+++ b/db/migrate/20181221121805_create_theme_translation_override.rb
@@ -10,7 +10,9 @@ class CreateThemeTranslationOverride < ActiveRecord::Migration[5.2]
t.timestamps null: false
t.index :theme_id
- t.index [:theme_id, :locale, :translation_key], unique: true, name: 'theme_translation_overrides_unique'
+ t.index %i[theme_id locale translation_key],
+ unique: true,
+ name: "theme_translation_overrides_unique"
end
end
end
diff --git a/db/migrate/20190103060819_force_rebake_on_posts_with_images.rb b/db/migrate/20190103060819_force_rebake_on_posts_with_images.rb
index 535ea684a66..7d9f622b0f1 100644
--- a/db/migrate/20190103060819_force_rebake_on_posts_with_images.rb
+++ b/db/migrate/20190103060819_force_rebake_on_posts_with_images.rb
@@ -2,7 +2,6 @@
class ForceRebakeOnPostsWithImages < ActiveRecord::Migration[5.2]
def up
-
# commit message has more info:
# Picking up changes with pngquant, placeholder image, new image magick, retina images
diff --git a/db/migrate/20190103065652_remove_uploaded_meta_id_from_category.rb b/db/migrate/20190103065652_remove_uploaded_meta_id_from_category.rb
index 9aba22fa065..24c4501dffd 100644
--- a/db/migrate/20190103065652_remove_uploaded_meta_id_from_category.rb
+++ b/db/migrate/20190103065652_remove_uploaded_meta_id_from_category.rb
@@ -1,16 +1,12 @@
# frozen_string_literal: true
-require 'migration/column_dropper'
+require "migration/column_dropper"
class RemoveUploadedMetaIdFromCategory < ActiveRecord::Migration[5.2]
- DROPPED_COLUMNS ||= {
- categories: %i{uploaded_meta_id}
- }
+ DROPPED_COLUMNS ||= { categories: %i[uploaded_meta_id] }
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
diff --git a/db/migrate/20190103160533_create_reviewables.rb b/db/migrate/20190103160533_create_reviewables.rb
index 79d13f889e8..564446abc40 100644
--- a/db/migrate/20190103160533_create_reviewables.rb
+++ b/db/migrate/20190103160533_create_reviewables.rb
@@ -36,8 +36,8 @@ class CreateReviewables < ActiveRecord::Migration[5.2]
end
add_index :reviewables, :status
- add_index :reviewables, [:status, :type]
- add_index :reviewables, [:status, :score]
- add_index :reviewables, [:type, :target_id], unique: true
+ add_index :reviewables, %i[status type]
+ add_index :reviewables, %i[status score]
+ add_index :reviewables, %i[type target_id], unique: true
end
end
diff --git a/db/migrate/20190103185626_create_reviewable_users.rb b/db/migrate/20190103185626_create_reviewable_users.rb
index e1306be9fda..574f47fcfcc 100644
--- a/db/migrate/20190103185626_create_reviewable_users.rb
+++ b/db/migrate/20190103185626_create_reviewable_users.rb
@@ -3,7 +3,9 @@
class CreateReviewableUsers < ActiveRecord::Migration[5.2]
def up
# Create reviewables for approved users
- if DB.query_single("SELECT 1 FROM site_settings WHERE name = 'must_approve_users' AND value = 't'").first
+ if DB.query_single(
+ "SELECT 1 FROM site_settings WHERE name = 'must_approve_users' AND value = 't'",
+ ).first
execute(<<~SQL)
INSERT INTO reviewables (
type,
diff --git a/db/migrate/20190106041015_add_topic_id_index_to_user_histories.rb b/db/migrate/20190106041015_add_topic_id_index_to_user_histories.rb
index d3b6d6366d2..4b9f435a121 100644
--- a/db/migrate/20190106041015_add_topic_id_index_to_user_histories.rb
+++ b/db/migrate/20190106041015_add_topic_id_index_to_user_histories.rb
@@ -2,6 +2,6 @@
class AddTopicIdIndexToUserHistories < ActiveRecord::Migration[5.2]
def change
- add_index :user_histories, [:topic_id, :target_user_id, :action]
+ add_index :user_histories, %i[topic_id target_user_id action]
end
end
diff --git a/db/migrate/20190110212005_create_reviewable_histories.rb b/db/migrate/20190110212005_create_reviewable_histories.rb
index 6bf9ae5b32b..02663d09692 100644
--- a/db/migrate/20190110212005_create_reviewable_histories.rb
+++ b/db/migrate/20190110212005_create_reviewable_histories.rb
@@ -7,7 +7,7 @@ class CreateReviewableHistories < ActiveRecord::Migration[5.2]
t.integer :reviewable_history_type, null: false
t.integer :status, null: false
t.integer :created_by_id, null: false
- t.json :edited, null: true
+ t.json :edited, null: true
t.timestamps
end
diff --git a/db/migrate/20190130163001_migrate_reviewable_flagged_posts.rb b/db/migrate/20190130163001_migrate_reviewable_flagged_posts.rb
index a2c18668696..286a77d6936 100644
--- a/db/migrate/20190130163001_migrate_reviewable_flagged_posts.rb
+++ b/db/migrate/20190130163001_migrate_reviewable_flagged_posts.rb
@@ -2,7 +2,6 @@
class MigrateReviewableFlaggedPosts < ActiveRecord::Migration[5.2]
def up
-
# for the migration we'll do 1.0 + trust_level and not take into account user flagging accuracy
# It should be good enough for old flags whose scores are not as important as pending flags.
execute(<<~SQL)
diff --git a/db/migrate/20190205104116_drop_unused_auth_tables.rb b/db/migrate/20190205104116_drop_unused_auth_tables.rb
index 99fa6f75850..e21ea59bfc2 100644
--- a/db/migrate/20190205104116_drop_unused_auth_tables.rb
+++ b/db/migrate/20190205104116_drop_unused_auth_tables.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'migration/table_dropper'
+require "migration/table_dropper"
class DropUnusedAuthTables < ActiveRecord::Migration[5.2]
def change
diff --git a/db/migrate/20190208144706_drop_unused_auth_tables_again.rb b/db/migrate/20190208144706_drop_unused_auth_tables_again.rb
index 6fb208c6c83..fc910b24d99 100644
--- a/db/migrate/20190208144706_drop_unused_auth_tables_again.rb
+++ b/db/migrate/20190208144706_drop_unused_auth_tables_again.rb
@@ -1,17 +1,12 @@
# frozen_string_literal: true
-require 'migration/table_dropper'
+require "migration/table_dropper"
class DropUnusedAuthTablesAgain < ActiveRecord::Migration[5.2]
- DROPPED_TABLES ||= %i{
- facebook_user_infos
- twitter_user_infos
- }
+ DROPPED_TABLES ||= %i[facebook_user_infos twitter_user_infos]
def up
- DROPPED_TABLES.each do |table|
- Migration::TableDropper.execute_drop(table)
- end
+ DROPPED_TABLES.each { |table| Migration::TableDropper.execute_drop(table) }
end
def down
diff --git a/db/migrate/20190225133654_add_ignored_users_table.rb b/db/migrate/20190225133654_add_ignored_users_table.rb
index d2f164a984a..15a440c191e 100644
--- a/db/migrate/20190225133654_add_ignored_users_table.rb
+++ b/db/migrate/20190225133654_add_ignored_users_table.rb
@@ -8,7 +8,7 @@ class AddIgnoredUsersTable < ActiveRecord::Migration[5.2]
t.timestamps null: false
end
- add_index :ignored_users, [:user_id, :ignored_user_id], unique: true
- add_index :ignored_users, [:ignored_user_id, :user_id], unique: true
+ add_index :ignored_users, %i[user_id ignored_user_id], unique: true
+ add_index :ignored_users, %i[ignored_user_id user_id], unique: true
end
end
diff --git a/db/migrate/20190312194528_drop_email_user_options_columns.rb b/db/migrate/20190312194528_drop_email_user_options_columns.rb
index 1b4203b1754..1367ba3871c 100644
--- a/db/migrate/20190312194528_drop_email_user_options_columns.rb
+++ b/db/migrate/20190312194528_drop_email_user_options_columns.rb
@@ -1,20 +1,12 @@
# frozen_string_literal: true
-require 'migration/column_dropper'
+require "migration/column_dropper"
class DropEmailUserOptionsColumns < ActiveRecord::Migration[5.2]
- DROPPED_COLUMNS ||= {
- user_options: %i{
- email_direct
- email_private_messages
- email_always
- },
- }
+ DROPPED_COLUMNS ||= { user_options: %i[email_direct email_private_messages email_always] }
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
diff --git a/db/migrate/20190313134642_migrate_default_user_email_options.rb b/db/migrate/20190313134642_migrate_default_user_email_options.rb
index 961789b92ae..3048456aeda 100644
--- a/db/migrate/20190313134642_migrate_default_user_email_options.rb
+++ b/db/migrate/20190313134642_migrate_default_user_email_options.rb
@@ -5,13 +5,18 @@ class MigrateDefaultUserEmailOptions < ActiveRecord::Migration[5.2]
# see UserOption.email_level_types
# always = 0, only_while_away: 1, never: 2
- email_always = DB.query_single("SELECT value FROM site_settings WHERE name = 'default_email_always'").first
- email_direct = DB.query_single("SELECT value FROM site_settings WHERE name = 'default_email_direct'").first
- email_personal_messages = DB.query_single("SELECT value FROM site_settings WHERE name = 'default_email_personal_messages'").first
+ email_always =
+ DB.query_single("SELECT value FROM site_settings WHERE name = 'default_email_always'").first
+ email_direct =
+ DB.query_single("SELECT value FROM site_settings WHERE name = 'default_email_direct'").first
+ email_personal_messages =
+ DB.query_single(
+ "SELECT value FROM site_settings WHERE name = 'default_email_personal_messages'",
+ ).first
default_email_level = nil
- default_email_level = 0 if email_direct != 'f' && email_always == 't'
- default_email_level = 2 if email_direct == 'f'
+ default_email_level = 0 if email_direct != "f" && email_always == "t"
+ default_email_level = 2 if email_direct == "f"
unless default_email_level.nil?
execute "INSERT INTO site_settings (name, data_type, value, created_at, updated_at)
@@ -19,8 +24,8 @@ class MigrateDefaultUserEmailOptions < ActiveRecord::Migration[5.2]
end
default_email_messages_level = nil
- default_email_messages_level = 0 if email_personal_messages != 'f' && email_always == 't'
- default_email_messages_level = 2 if email_personal_messages == 'f'
+ default_email_messages_level = 0 if email_personal_messages != "f" && email_always == "t"
+ default_email_messages_level = 2 if email_personal_messages == "f"
unless default_email_messages_level.nil?
execute "INSERT INTO site_settings (name, data_type, value, created_at, updated_at)
diff --git a/db/migrate/20190313171338_add_indexes_to_reviewables.rb b/db/migrate/20190313171338_add_indexes_to_reviewables.rb
index 245ad2a916f..1ad7c2cbbb6 100644
--- a/db/migrate/20190313171338_add_indexes_to_reviewables.rb
+++ b/db/migrate/20190313171338_add_indexes_to_reviewables.rb
@@ -3,11 +3,11 @@
class AddIndexesToReviewables < ActiveRecord::Migration[5.2]
def up
remove_index :reviewables, :status
- add_index :reviewables, [:status, :created_at]
+ add_index :reviewables, %i[status created_at]
end
def down
- remove_index :reviewables, [:status, :created_at]
+ remove_index :reviewables, %i[status created_at]
add_index :reviewables, :status
end
end
diff --git a/db/migrate/20190315174428_migrate_flag_history.rb b/db/migrate/20190315174428_migrate_flag_history.rb
index dbeefd3c111..4fa90d30e53 100644
--- a/db/migrate/20190315174428_migrate_flag_history.rb
+++ b/db/migrate/20190315174428_migrate_flag_history.rb
@@ -2,7 +2,6 @@
class MigrateFlagHistory < ActiveRecord::Migration[5.2]
def up
-
# Migrate Created History
execute(<<~SQL)
INSERT INTO reviewable_histories (
diff --git a/db/migrate/20190320091323_add_index_post_action_type_id_disagreed_at_on_post_actions.rb b/db/migrate/20190320091323_add_index_post_action_type_id_disagreed_at_on_post_actions.rb
index 6e4344236f1..53606a1d0a4 100644
--- a/db/migrate/20190320091323_add_index_post_action_type_id_disagreed_at_on_post_actions.rb
+++ b/db/migrate/20190320091323_add_index_post_action_type_id_disagreed_at_on_post_actions.rb
@@ -2,7 +2,6 @@
class AddIndexPostActionTypeIdDisagreedAtOnPostActions < ActiveRecord::Migration[5.2]
def change
- add_index :post_actions, [:post_action_type_id, :disagreed_at],
- where: "(disagreed_at IS NULL)"
+ add_index :post_actions, %i[post_action_type_id disagreed_at], where: "(disagreed_at IS NULL)"
end
end
diff --git a/db/migrate/20190321072029_add_index_method_enabled_on_user_second_factors.rb b/db/migrate/20190321072029_add_index_method_enabled_on_user_second_factors.rb
index 2f915d0c101..1afb271a226 100644
--- a/db/migrate/20190321072029_add_index_method_enabled_on_user_second_factors.rb
+++ b/db/migrate/20190321072029_add_index_method_enabled_on_user_second_factors.rb
@@ -2,6 +2,6 @@
class AddIndexMethodEnabledOnUserSecondFactors < ActiveRecord::Migration[5.2]
def change
- add_index :user_second_factors, [:method, :enabled]
+ add_index :user_second_factors, %i[method enabled]
end
end
diff --git a/db/migrate/20190327205525_require_reviewable_scores.rb b/db/migrate/20190327205525_require_reviewable_scores.rb
index 916aed09398..b3cb534800d 100644
--- a/db/migrate/20190327205525_require_reviewable_scores.rb
+++ b/db/migrate/20190327205525_require_reviewable_scores.rb
@@ -2,7 +2,12 @@
class RequireReviewableScores < ActiveRecord::Migration[5.2]
def up
- min_score = DB.query_single("SELECT value FROM site_settings WHERE name = 'min_score_default_visibility'")[0].to_f
+ min_score =
+ DB.query_single(
+ "SELECT value FROM site_settings WHERE name = 'min_score_default_visibility'",
+ )[
+ 0
+ ].to_f
min_score = 1.0 if (min_score < 1.0)
execute(<<~SQL)
diff --git a/db/migrate/20190402024053_add_first_unread_at_to_user_stats.rb b/db/migrate/20190402024053_add_first_unread_at_to_user_stats.rb
index df0631443d4..adecf40d155 100644
--- a/db/migrate/20190402024053_add_first_unread_at_to_user_stats.rb
+++ b/db/migrate/20190402024053_add_first_unread_at_to_user_stats.rb
@@ -6,7 +6,11 @@ class AddFirstUnreadAtToUserStats < ActiveRecord::Migration[5.2]
def up
# so we can rerun this if the index creation fails out of ddl
if !column_exists?(:user_stats, :first_unread_at)
- add_column :user_stats, :first_unread_at, :datetime, null: false, default: -> { 'CURRENT_TIMESTAMP' }
+ add_column :user_stats,
+ :first_unread_at,
+ :datetime,
+ null: false,
+ default: -> { "CURRENT_TIMESTAMP" }
end
execute <<~SQL
@@ -19,19 +23,35 @@ class AddFirstUnreadAtToUserStats < ActiveRecord::Migration[5.2]
# since DDL transactions are disabled we got to check
# this could potentially fail half way and we want it to recover
if !index_exists?(
- :topics,
- # the big list of columns here is not really needed, but ... why not
- [:updated_at, :visible, :highest_staff_post_number, :highest_post_number, :category_id, :created_at, :id],
- name: 'index_topics_on_updated_at_public'
- )
+ :topics,
+ # the big list of columns here is not really needed, but ... why not
+ %i[
+ updated_at
+ visible
+ highest_staff_post_number
+ highest_post_number
+ category_id
+ created_at
+ id
+ ],
+ name: "index_topics_on_updated_at_public",
+ )
# this is quite a big index to carry, but we need it to optimise home page initial load
# by covering all these columns we are able to quickly retrieve the set of topics that were
# updated in the last N days. We perform a ranged lookup and selectivity may vary a lot
add_index :topics,
- [:updated_at, :visible, :highest_staff_post_number, :highest_post_number, :category_id, :created_at, :id],
- algorithm: :concurrently,
- name: 'index_topics_on_updated_at_public',
- where: "(topics.archetype <> 'private_message') AND (topics.deleted_at IS NULL)"
+ %i[
+ updated_at
+ visible
+ highest_staff_post_number
+ highest_post_number
+ category_id
+ created_at
+ id
+ ],
+ algorithm: :concurrently,
+ name: "index_topics_on_updated_at_public",
+ where: "(topics.archetype <> 'private_message') AND (topics.deleted_at IS NULL)"
end
end
diff --git a/db/migrate/20190405044140_add_index_action_type_created_at_on_user_actions.rb b/db/migrate/20190405044140_add_index_action_type_created_at_on_user_actions.rb
index c04f43dbec3..d0ac774de72 100644
--- a/db/migrate/20190405044140_add_index_action_type_created_at_on_user_actions.rb
+++ b/db/migrate/20190405044140_add_index_action_type_created_at_on_user_actions.rb
@@ -2,6 +2,6 @@
class AddIndexActionTypeCreatedAtOnUserActions < ActiveRecord::Migration[5.2]
def change
- add_index :user_actions, [:action_type, :created_at]
+ add_index :user_actions, %i[action_type created_at]
end
end
diff --git a/db/migrate/20190408072550_add_index_id_baked_version_on_posts.rb b/db/migrate/20190408072550_add_index_id_baked_version_on_posts.rb
index 6035119b47c..08d22cbf685 100644
--- a/db/migrate/20190408072550_add_index_id_baked_version_on_posts.rb
+++ b/db/migrate/20190408072550_add_index_id_baked_version_on_posts.rb
@@ -2,8 +2,6 @@
class AddIndexIdBakedVersionOnPosts < ActiveRecord::Migration[5.2]
def change
- add_index :posts, [:id, :baked_version],
- order: { id: :desc },
- where: "(deleted_at IS NULL)"
+ add_index :posts, %i[id baked_version], order: { id: :desc }, where: "(deleted_at IS NULL)"
end
end
diff --git a/db/migrate/20190408082101_add_search_data_indexes.rb b/db/migrate/20190408082101_add_search_data_indexes.rb
index bb20a59530d..cadc7b08453 100644
--- a/db/migrate/20190408082101_add_search_data_indexes.rb
+++ b/db/migrate/20190408082101_add_search_data_indexes.rb
@@ -2,7 +2,7 @@
class AddSearchDataIndexes < ActiveRecord::Migration[5.2]
def change
- add_index :topic_search_data, [:topic_id, :version, :locale]
- add_index :post_search_data, [:post_id, :version, :locale]
+ add_index :topic_search_data, %i[topic_id version locale]
+ add_index :post_search_data, %i[post_id version locale]
end
end
diff --git a/db/migrate/20190409054736_add_index_for_rebake_old_on_posts.rb b/db/migrate/20190409054736_add_index_for_rebake_old_on_posts.rb
index 900ea7de38f..76b84ff84b0 100644
--- a/db/migrate/20190409054736_add_index_for_rebake_old_on_posts.rb
+++ b/db/migrate/20190409054736_add_index_for_rebake_old_on_posts.rb
@@ -9,11 +9,14 @@ class AddIndexForRebakeOldOnPosts < ActiveRecord::Migration[5.2]
end
if !index_exists?(:posts, :index_for_rebake_old)
- add_index :posts, :id,
- order: { id: :desc },
- where: "(baked_version IS NULL OR baked_version < 2) AND deleted_at IS NULL",
- name: :index_for_rebake_old,
- algorithm: :concurrently
+ add_index :posts,
+ :id,
+ order: {
+ id: :desc,
+ },
+ where: "(baked_version IS NULL OR baked_version < 2) AND deleted_at IS NULL",
+ name: :index_for_rebake_old,
+ algorithm: :concurrently
end
end
diff --git a/db/migrate/20190412161430_add_created_by_index_to_reviewables.rb b/db/migrate/20190412161430_add_created_by_index_to_reviewables.rb
index 02187168b8e..27b0c86df7c 100644
--- a/db/migrate/20190412161430_add_created_by_index_to_reviewables.rb
+++ b/db/migrate/20190412161430_add_created_by_index_to_reviewables.rb
@@ -2,6 +2,6 @@
class AddCreatedByIndexToReviewables < ActiveRecord::Migration[5.2]
def change
- add_index :reviewables, [:topic_id, :status, :created_by_id]
+ add_index :reviewables, %i[topic_id status created_by_id]
end
end
diff --git a/db/migrate/20190414162753_rename_post_notices.rb b/db/migrate/20190414162753_rename_post_notices.rb
index 997fb5f9071..098de360459 100644
--- a/db/migrate/20190414162753_rename_post_notices.rb
+++ b/db/migrate/20190414162753_rename_post_notices.rb
@@ -2,8 +2,16 @@
class RenamePostNotices < ActiveRecord::Migration[5.2]
def up
- add_index :post_custom_fields, :post_id, unique: true, name: "index_post_custom_fields_on_notice_type", where: "name = 'notice_type'"
- add_index :post_custom_fields, :post_id, unique: true, name: "index_post_custom_fields_on_notice_args", where: "name = 'notice_args'"
+ add_index :post_custom_fields,
+ :post_id,
+ unique: true,
+ name: "index_post_custom_fields_on_notice_type",
+ where: "name = 'notice_type'"
+ add_index :post_custom_fields,
+ :post_id,
+ unique: true,
+ name: "index_post_custom_fields_on_notice_args",
+ where: "name = 'notice_args'"
# Split site setting `min_post_notice_tl` into `new_user_notice_tl` and `returning_user_notice_tl`.
execute <<~SQL
diff --git a/db/migrate/20190418113814_add_unique_index_to_group_requests.rb b/db/migrate/20190418113814_add_unique_index_to_group_requests.rb
index 54b0e85c660..cc266dad400 100644
--- a/db/migrate/20190418113814_add_unique_index_to_group_requests.rb
+++ b/db/migrate/20190418113814_add_unique_index_to_group_requests.rb
@@ -3,6 +3,6 @@
class AddUniqueIndexToGroupRequests < ActiveRecord::Migration[5.2]
def change
execute "DELETE FROM group_requests WHERE id NOT IN (SELECT MIN(id) FROM group_requests GROUP BY group_id, user_id)"
- add_index :group_requests, [:group_id, :user_id], unique: true
+ add_index :group_requests, %i[group_id user_id], unique: true
end
end
diff --git a/db/migrate/20190424065841_add_post_image_indexes.rb b/db/migrate/20190424065841_add_post_image_indexes.rb
index 496358bd459..25027b8bdec 100644
--- a/db/migrate/20190424065841_add_post_image_indexes.rb
+++ b/db/migrate/20190424065841_add_post_image_indexes.rb
@@ -2,13 +2,7 @@
class AddPostImageIndexes < ActiveRecord::Migration[5.2]
def change
-
- %w{
- large_images
- broken_images
- downloaded_images
- }.each do |field|
-
+ %w[large_images broken_images downloaded_images].each do |field|
execute <<~SQL
DELETE FROM post_custom_fields f
WHERE name = '#{field}' AND id > (
@@ -17,10 +11,11 @@ class AddPostImageIndexes < ActiveRecord::Migration[5.2]
)
SQL
- add_index :post_custom_fields, [:post_id],
- name: "post_custom_field_#{field}_idx",
- unique: true,
- where: "name = '#{field}'"
+ add_index :post_custom_fields,
+ [:post_id],
+ name: "post_custom_field_#{field}_idx",
+ unique: true,
+ where: "name = '#{field}'"
end
end
end
diff --git a/db/migrate/20190426011148_add_upload_foreign_keys_to_user_profiles.rb b/db/migrate/20190426011148_add_upload_foreign_keys_to_user_profiles.rb
index c0918769b2f..8ef54c91909 100644
--- a/db/migrate/20190426011148_add_upload_foreign_keys_to_user_profiles.rb
+++ b/db/migrate/20190426011148_add_upload_foreign_keys_to_user_profiles.rb
@@ -1,10 +1,10 @@
# frozen_string_literal: true
-require 'migration/column_dropper'
+require "migration/column_dropper"
class AddUploadForeignKeysToUserProfiles < ActiveRecord::Migration[5.2]
def up
- %i{profile_background card_background}.each do |column|
+ %i[profile_background card_background].each do |column|
Migration::ColumnDropper.mark_readonly(:user_profiles, column)
end
diff --git a/db/migrate/20190426074404_add_missing_user_destroyer_indexes.rb b/db/migrate/20190426074404_add_missing_user_destroyer_indexes.rb
index 9ef1e93ae37..91430e287a0 100644
--- a/db/migrate/20190426074404_add_missing_user_destroyer_indexes.rb
+++ b/db/migrate/20190426074404_add_missing_user_destroyer_indexes.rb
@@ -3,9 +3,9 @@
class AddMissingUserDestroyerIndexes < ActiveRecord::Migration[5.2]
def change
# these indexes are required to make deletions of users fast
- add_index :user_actions, [:target_user_id], where: 'target_user_id IS NOT NULL'
+ add_index :user_actions, [:target_user_id], where: "target_user_id IS NOT NULL"
add_index :post_actions, [:user_id]
- add_index :user_uploads, [:user_id, :upload_id]
+ add_index :user_uploads, %i[user_id upload_id]
add_index :user_auth_token_logs, [:user_id]
add_index :topic_links, [:user_id]
end
diff --git a/db/migrate/20190426123026_add_incoming_email_by_user_id_index.rb b/db/migrate/20190426123026_add_incoming_email_by_user_id_index.rb
index ecbe8381a91..dd886d8b634 100644
--- a/db/migrate/20190426123026_add_incoming_email_by_user_id_index.rb
+++ b/db/migrate/20190426123026_add_incoming_email_by_user_id_index.rb
@@ -2,6 +2,6 @@
class AddIncomingEmailByUserIdIndex < ActiveRecord::Migration[5.2]
def change
- add_index :incoming_emails, [:user_id], where: 'user_id IS NOT NULL'
+ add_index :incoming_emails, [:user_id], where: "user_id IS NOT NULL"
end
end
diff --git a/db/migrate/20190502223613_add_bounce_key_index_on_email_logs.rb b/db/migrate/20190502223613_add_bounce_key_index_on_email_logs.rb
index 83ccf913d27..8e948a5edb3 100644
--- a/db/migrate/20190502223613_add_bounce_key_index_on_email_logs.rb
+++ b/db/migrate/20190502223613_add_bounce_key_index_on_email_logs.rb
@@ -2,6 +2,6 @@
class AddBounceKeyIndexOnEmailLogs < ActiveRecord::Migration[5.2]
def change
- add_index :email_logs, [:bounce_key], unique: true, where: 'bounce_key IS NOT NULL'
+ add_index :email_logs, [:bounce_key], unique: true, where: "bounce_key IS NOT NULL"
end
end
diff --git a/db/migrate/20190508193900_add_missing_uploads_ignored_index_to_post_custom_fields.rb b/db/migrate/20190508193900_add_missing_uploads_ignored_index_to_post_custom_fields.rb
index 1f6978225c0..e9a03468f0c 100644
--- a/db/migrate/20190508193900_add_missing_uploads_ignored_index_to_post_custom_fields.rb
+++ b/db/migrate/20190508193900_add_missing_uploads_ignored_index_to_post_custom_fields.rb
@@ -2,6 +2,10 @@
class AddMissingUploadsIgnoredIndexToPostCustomFields < ActiveRecord::Migration[5.2]
def change
- add_index :post_custom_fields, :post_id, unique: true, where: "name = 'missing uploads ignored'", name: "index_post_id_where_missing_uploads_ignored"
+ add_index :post_custom_fields,
+ :post_id,
+ unique: true,
+ where: "name = 'missing uploads ignored'",
+ name: "index_post_id_where_missing_uploads_ignored"
end
end
diff --git a/db/migrate/20190529002752_add_unique_constraint_to_shadow_accounts.rb b/db/migrate/20190529002752_add_unique_constraint_to_shadow_accounts.rb
index 78a8a3f4f73..d87c25696f6 100644
--- a/db/migrate/20190529002752_add_unique_constraint_to_shadow_accounts.rb
+++ b/db/migrate/20190529002752_add_unique_constraint_to_shadow_accounts.rb
@@ -1,7 +1,6 @@
# frozen_string_literal: true
class AddUniqueConstraintToShadowAccounts < ActiveRecord::Migration[5.2]
-
def up
create_table :anonymous_users do |t|
t.integer :user_id, null: false
@@ -10,7 +9,7 @@ class AddUniqueConstraintToShadowAccounts < ActiveRecord::Migration[5.2]
t.timestamps
t.index [:user_id], unique: true
- t.index [:master_user_id], unique: true, where: 'active'
+ t.index [:master_user_id], unique: true, where: "active"
end
rows = DB.exec <<~SQL
@@ -24,9 +23,7 @@ class AddUniqueConstraintToShadowAccounts < ActiveRecord::Migration[5.2]
)
SQL
- if rows > 0
- STDERR.puts "Removed #{rows} duplicate shadow users"
- end
+ STDERR.puts "Removed #{rows} duplicate shadow users" if rows > 0
rows = DB.exec <<~SQL
INSERT INTO anonymous_users(user_id, master_user_id, created_at, updated_at, active)
@@ -43,9 +40,7 @@ class AddUniqueConstraintToShadowAccounts < ActiveRecord::Migration[5.2]
WHERE name = 'master_id' AND a.user_id IS NULL
SQL
- if rows > 0
- STDERR.puts "Migrated #{rows} anon users to new structure"
- end
+ STDERR.puts "Migrated #{rows} anon users to new structure" if rows > 0
DB.exec <<~SQL
DELETE FROM user_custom_fields
diff --git a/db/migrate/20190621095105_remove_notification_level_from_category_user_indexes.rb b/db/migrate/20190621095105_remove_notification_level_from_category_user_indexes.rb
index 587e2cf4f92..81bb15edd11 100644
--- a/db/migrate/20190621095105_remove_notification_level_from_category_user_indexes.rb
+++ b/db/migrate/20190621095105_remove_notification_level_from_category_user_indexes.rb
@@ -9,22 +9,30 @@ DELETE FROM category_users cu USING category_users cu1
cu.notification_level < cu1.notification_level
SQL
- remove_index :category_users, name: 'idx_category_users_u1'
- remove_index :category_users, name: 'idx_category_users_u2'
+ remove_index :category_users, name: "idx_category_users_u1"
+ remove_index :category_users, name: "idx_category_users_u2"
- add_index :category_users, [:user_id, :category_id],
- name: 'idx_category_users_user_id_category_id', unique: true
- add_index :category_users, [:category_id, :user_id],
- name: 'idx_category_users_category_id_user_id', unique: true
+ add_index :category_users,
+ %i[user_id category_id],
+ name: "idx_category_users_user_id_category_id",
+ unique: true
+ add_index :category_users,
+ %i[category_id user_id],
+ name: "idx_category_users_category_id_user_id",
+ unique: true
end
def down
- remove_index :category_users, name: 'idx_category_users_user_id_category_id'
- remove_index :category_users, name: 'idx_category_users_category_id_user_id'
+ remove_index :category_users, name: "idx_category_users_user_id_category_id"
+ remove_index :category_users, name: "idx_category_users_category_id_user_id"
- add_index :category_users, [:user_id, :category_id, :notification_level],
- name: 'idx_category_users_u1', unique: true
- add_index :category_users, [:category_id, :user_id, :notification_level],
- name: 'idx_category_users_u2', unique: true
+ add_index :category_users,
+ %i[user_id category_id notification_level],
+ name: "idx_category_users_u1",
+ unique: true
+ add_index :category_users,
+ %i[category_id user_id notification_level],
+ name: "idx_category_users_u2",
+ unique: true
end
end
diff --git a/db/migrate/20190716124050_remove_via_email_from_invite.rb b/db/migrate/20190716124050_remove_via_email_from_invite.rb
index 29e91f39edb..f0d8b4779dd 100644
--- a/db/migrate/20190716124050_remove_via_email_from_invite.rb
+++ b/db/migrate/20190716124050_remove_via_email_from_invite.rb
@@ -1,16 +1,12 @@
# frozen_string_literal: true
-require 'migration/column_dropper'
+require "migration/column_dropper"
class RemoveViaEmailFromInvite < ActiveRecord::Migration[5.2]
- DROPPED_COLUMNS ||= {
- invites: %i{via_email}
- }
+ DROPPED_COLUMNS ||= { invites: %i[via_email] }
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
diff --git a/db/migrate/20190716173854_add_secure_to_uploads.rb b/db/migrate/20190716173854_add_secure_to_uploads.rb
index 837cff98f68..e2c79aad327 100644
--- a/db/migrate/20190716173854_add_secure_to_uploads.rb
+++ b/db/migrate/20190716173854_add_secure_to_uploads.rb
@@ -4,20 +4,18 @@ class AddSecureToUploads < ActiveRecord::Migration[5.2]
def up
add_column :uploads, :secure, :boolean, default: false, null: false
- prevent_anons_from_downloading_files = \
- DB.query_single("SELECT value FROM site_settings WHERE name = 'prevent_anons_from_downloading_files'").first == 't'
+ prevent_anons_from_downloading_files =
+ DB.query_single(
+ "SELECT value FROM site_settings WHERE name = 'prevent_anons_from_downloading_files'",
+ ).first == "t"
- if prevent_anons_from_downloading_files
- execute(
- <<-SQL
+ execute(<<-SQL) if prevent_anons_from_downloading_files
UPDATE uploads SET secure = 't' WHERE id IN (
SELECT DISTINCT(uploads.id) FROM uploads
INNER JOIN post_uploads ON post_uploads.upload_id = uploads.id
WHERE LOWER(original_filename) NOT SIMILAR TO '%\.(jpg|jpeg|png|gif|svg|ico)'
)
SQL
- )
- end
end
def down
diff --git a/db/migrate/20190717133743_migrate_group_list_site_settings.rb b/db/migrate/20190717133743_migrate_group_list_site_settings.rb
index 6a81fe17b0b..acd7bb8acdd 100644
--- a/db/migrate/20190717133743_migrate_group_list_site_settings.rb
+++ b/db/migrate/20190717133743_migrate_group_list_site_settings.rb
@@ -10,7 +10,7 @@ class MigrateGroupListSiteSettings < ActiveRecord::Migration[5.2]
end
def migrate_value(from, to)
- cast_type = from == :id ? '::int[]' : ''
+ cast_type = from == :id ? "::int[]" : ""
DB.exec <<~SQL
UPDATE site_settings
SET value = COALESCE(array_to_string(
diff --git a/db/migrate/20190904104533_create_user_security_keys.rb b/db/migrate/20190904104533_create_user_security_keys.rb
index acccab96856..c9bf5ed9b75 100644
--- a/db/migrate/20190904104533_create_user_security_keys.rb
+++ b/db/migrate/20190904104533_create_user_security_keys.rb
@@ -19,8 +19,6 @@ class CreateUserSecurityKeys < ActiveRecord::Migration[5.2]
end
def down
- if table_exists?(:user_security_keys)
- drop_table(:user_security_keys)
- end
+ drop_table(:user_security_keys) if table_exists?(:user_security_keys)
end
end
diff --git a/db/migrate/20190917100006_add_enabled_index_to_user_security_key.rb b/db/migrate/20190917100006_add_enabled_index_to_user_security_key.rb
index 14b9c027c28..8cc5be79589 100644
--- a/db/migrate/20190917100006_add_enabled_index_to_user_security_key.rb
+++ b/db/migrate/20190917100006_add_enabled_index_to_user_security_key.rb
@@ -2,6 +2,6 @@
class AddEnabledIndexToUserSecurityKey < ActiveRecord::Migration[6.0]
def change
- add_index :user_security_keys, [:factor_type, :enabled]
+ add_index :user_security_keys, %i[factor_type enabled]
end
end
diff --git a/db/migrate/20191008124357_add_unique_index_categories_on_slug.rb b/db/migrate/20191008124357_add_unique_index_categories_on_slug.rb
index 7c9dad67e3b..e5aeecc1d97 100644
--- a/db/migrate/20191008124357_add_unique_index_categories_on_slug.rb
+++ b/db/migrate/20191008124357_add_unique_index_categories_on_slug.rb
@@ -4,8 +4,8 @@ class AddUniqueIndexCategoriesOnSlug < ActiveRecord::Migration[6.0]
def change
add_index(
:categories,
- 'COALESCE(parent_category_id, -1), slug',
- name: 'unique_index_categories_on_slug'
+ "COALESCE(parent_category_id, -1), slug",
+ name: "unique_index_categories_on_slug",
)
end
end
diff --git a/db/migrate/20191011131041_migrate_decompressed_file_max_size_mb.rb b/db/migrate/20191011131041_migrate_decompressed_file_max_size_mb.rb
index f3db85da390..6e8c551fdc5 100644
--- a/db/migrate/20191011131041_migrate_decompressed_file_max_size_mb.rb
+++ b/db/migrate/20191011131041_migrate_decompressed_file_max_size_mb.rb
@@ -2,16 +2,17 @@
class MigrateDecompressedFileMaxSizeMb < ActiveRecord::Migration[6.0]
def up
- current_value = DB.query_single("SELECT value FROM site_settings WHERE name ='decompressed_file_max_size_mb' ").first
+ current_value =
+ DB.query_single(
+ "SELECT value FROM site_settings WHERE name ='decompressed_file_max_size_mb' ",
+ ).first
- if current_value && current_value != '1000'
- DB.exec <<~SQL
+ DB.exec <<~SQL if current_value && current_value != "1000"
INSERT INTO site_settings (name, data_type, value, created_at, updated_at)
VALUES
('decompressed_theme_max_file_size_mb', 3, #{current_value}, current_timestamp, current_timestamp),
('decompressed_backup_max_file_size_mb', 3, #{current_value}, current_timestamp, current_timestamp)
SQL
- end
end
def down
diff --git a/db/migrate/20191016124059_fix_category_slugs_index.rb b/db/migrate/20191016124059_fix_category_slugs_index.rb
index 58b67b6fe65..ca26c0a95f0 100644
--- a/db/migrate/20191016124059_fix_category_slugs_index.rb
+++ b/db/migrate/20191016124059_fix_category_slugs_index.rb
@@ -2,14 +2,14 @@
class FixCategorySlugsIndex < ActiveRecord::Migration[6.0]
def change
- remove_index(:categories, name: 'unique_index_categories_on_slug')
+ remove_index(:categories, name: "unique_index_categories_on_slug")
add_index(
:categories,
- 'COALESCE(parent_category_id, -1), slug',
- name: 'unique_index_categories_on_slug',
+ "COALESCE(parent_category_id, -1), slug",
+ name: "unique_index_categories_on_slug",
where: "slug != ''",
- unique: true
+ unique: true,
)
end
end
diff --git a/db/migrate/20191017044811_add_draft_backup_tables.rb b/db/migrate/20191017044811_add_draft_backup_tables.rb
index 6177426c508..16902029f0a 100644
--- a/db/migrate/20191017044811_add_draft_backup_tables.rb
+++ b/db/migrate/20191017044811_add_draft_backup_tables.rb
@@ -2,7 +2,6 @@
class AddDraftBackupTables < ActiveRecord::Migration[6.0]
def change
-
create_table :backup_draft_topics do |t|
t.integer :user_id, null: false
t.integer :topic_id, null: false
@@ -16,7 +15,7 @@ class AddDraftBackupTables < ActiveRecord::Migration[6.0]
t.timestamps
end
- add_index :backup_draft_posts, [:user_id, :key], unique: true
+ add_index :backup_draft_posts, %i[user_id key], unique: true
add_index :backup_draft_posts, [:post_id], unique: true
add_index :backup_draft_topics, [:user_id], unique: true
diff --git a/db/migrate/20191022155215_add_index_to_oauth2_user_info.rb b/db/migrate/20191022155215_add_index_to_oauth2_user_info.rb
index 4c330ddae47..3228e5589bb 100644
--- a/db/migrate/20191022155215_add_index_to_oauth2_user_info.rb
+++ b/db/migrate/20191022155215_add_index_to_oauth2_user_info.rb
@@ -2,6 +2,6 @@
class AddIndexToOauth2UserInfo < ActiveRecord::Migration[6.0]
def change
- add_index :oauth2_user_infos, [:user_id, :provider]
+ add_index :oauth2_user_infos, %i[user_id provider]
end
end
diff --git a/db/migrate/20191025005204_amend_oauth2_user_info_index.rb b/db/migrate/20191025005204_amend_oauth2_user_info_index.rb
index 15dcf001d31..e9e18913130 100644
--- a/db/migrate/20191025005204_amend_oauth2_user_info_index.rb
+++ b/db/migrate/20191025005204_amend_oauth2_user_info_index.rb
@@ -4,6 +4,6 @@ class AmendOauth2UserInfoIndex < ActiveRecord::Migration[6.0]
def up
# remove old index which may have been unique
execute "DROP INDEX index_oauth2_user_infos_on_user_id_and_provider"
- add_index :oauth2_user_infos, [:user_id, :provider]
+ add_index :oauth2_user_infos, %i[user_id provider]
end
end
diff --git a/db/migrate/20191030112559_add_index_to_notifications.rb b/db/migrate/20191030112559_add_index_to_notifications.rb
index 69d36d2f4d6..48fa67fdbb8 100644
--- a/db/migrate/20191030112559_add_index_to_notifications.rb
+++ b/db/migrate/20191030112559_add_index_to_notifications.rb
@@ -4,8 +4,8 @@ class AddIndexToNotifications < ActiveRecord::Migration[6.0]
disable_ddl_transaction!
def up
- if !index_exists?(:notifications, [:topic_id, :post_number])
- add_index :notifications, [:topic_id, :post_number], algorithm: :concurrently
+ if !index_exists?(:notifications, %i[topic_id post_number])
+ add_index :notifications, %i[topic_id post_number], algorithm: :concurrently
end
end
diff --git a/db/migrate/20191031052711_add_granted_title_badge_id_to_user_profile.rb b/db/migrate/20191031052711_add_granted_title_badge_id_to_user_profile.rb
index f76ea34ef49..c37627a95cd 100644
--- a/db/migrate/20191031052711_add_granted_title_badge_id_to_user_profile.rb
+++ b/db/migrate/20191031052711_add_granted_title_badge_id_to_user_profile.rb
@@ -2,7 +2,13 @@
class AddGrantedTitleBadgeIdToUserProfile < ActiveRecord::Migration[6.0]
def up
- add_reference :user_profiles, :granted_title_badge, foreign_key: { to_table: :badges }, index: true, null: true
+ add_reference :user_profiles,
+ :granted_title_badge,
+ foreign_key: {
+ to_table: :badges,
+ },
+ index: true,
+ null: true
# update all the regular badge derived titles based
# on the normal badge name
diff --git a/db/migrate/20191101001705_add_banner_index_to_topics.rb b/db/migrate/20191101001705_add_banner_index_to_topics.rb
index ecafad00dec..7da2048e7e3 100644
--- a/db/migrate/20191101001705_add_banner_index_to_topics.rb
+++ b/db/migrate/20191101001705_add_banner_index_to_topics.rb
@@ -2,6 +2,10 @@
class AddBannerIndexToTopics < ActiveRecord::Migration[6.0]
def change
# this speeds up the process for finding banners on the site
- add_index :topics, [:id], name: 'index_topics_on_id_filtered_banner', where: "archetype = 'banner' AND deleted_at IS NULL", unique: true
+ add_index :topics,
+ [:id],
+ name: "index_topics_on_id_filtered_banner",
+ where: "archetype = 'banner' AND deleted_at IS NULL",
+ unique: true
end
end
diff --git a/db/migrate/20191107025140_add_index_to_last_seen_at_on_category_users.rb b/db/migrate/20191107025140_add_index_to_last_seen_at_on_category_users.rb
index e26839625db..59abd284b39 100644
--- a/db/migrate/20191107025140_add_index_to_last_seen_at_on_category_users.rb
+++ b/db/migrate/20191107025140_add_index_to_last_seen_at_on_category_users.rb
@@ -4,12 +4,12 @@ class AddIndexToLastSeenAtOnCategoryUsers < ActiveRecord::Migration[6.0]
disable_ddl_transaction!
def up
- if !index_exists?(:category_users, [:user_id, :last_seen_at])
- add_index :category_users, [:user_id, :last_seen_at], algorithm: :concurrently
+ if !index_exists?(:category_users, %i[user_id last_seen_at])
+ add_index :category_users, %i[user_id last_seen_at], algorithm: :concurrently
end
end
def down
- remove_index :category_users, [:user_id, :last_seen_at]
+ remove_index :category_users, %i[user_id last_seen_at]
end
end
diff --git a/db/migrate/20191107190330_remove_suppress_from_latest_from_category.rb b/db/migrate/20191107190330_remove_suppress_from_latest_from_category.rb
index 7d047c17c07..fb836afa632 100644
--- a/db/migrate/20191107190330_remove_suppress_from_latest_from_category.rb
+++ b/db/migrate/20191107190330_remove_suppress_from_latest_from_category.rb
@@ -1,15 +1,16 @@
# frozen_string_literal: true
class RemoveSuppressFromLatestFromCategory < ActiveRecord::Migration[6.0]
- DROPPED_COLUMNS ||= {
- categories: %i{suppress_from_latest}
- }
+ DROPPED_COLUMNS ||= { categories: %i[suppress_from_latest] }
def up
ids = DB.query_single("SELECT id::text FROM categories WHERE suppress_from_latest = TRUE")
if ids.present?
- muted_ids = DB.query_single("SELECT value from site_settings WHERE name = 'default_categories_muted'").first
+ muted_ids =
+ DB.query_single(
+ "SELECT value from site_settings WHERE name = 'default_categories_muted'",
+ ).first
ids += muted_ids.split("|") if muted_ids.present?
ids.uniq!
@@ -37,9 +38,7 @@ class RemoveSuppressFromLatestFromCategory < ActiveRecord::Migration[6.0]
end
end
- 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
diff --git a/db/migrate/20191108000414_add_unique_index_to_drafts.rb b/db/migrate/20191108000414_add_unique_index_to_drafts.rb
index f50d1b7c49d..2b34a8c2cae 100644
--- a/db/migrate/20191108000414_add_unique_index_to_drafts.rb
+++ b/db/migrate/20191108000414_add_unique_index_to_drafts.rb
@@ -2,7 +2,6 @@
class AddUniqueIndexToDrafts < ActiveRecord::Migration[6.0]
def up
-
execute <<~SQL
DELETE FROM drafts d1
USING (
@@ -17,8 +16,8 @@ class AddUniqueIndexToDrafts < ActiveRecord::Migration[6.0]
d1.id <> d2.id
SQL
- remove_index :drafts, [:user_id, :draft_key]
- add_index :drafts, [:user_id, :draft_key], unique: true
+ remove_index :drafts, %i[user_id draft_key]
+ add_index :drafts, %i[user_id draft_key], unique: true
end
def down
diff --git a/db/migrate/20191120015344_add_timezone_to_user_options.rb b/db/migrate/20191120015344_add_timezone_to_user_options.rb
index 8284842cf6c..57c17ebfc01 100644
--- a/db/migrate/20191120015344_add_timezone_to_user_options.rb
+++ b/db/migrate/20191120015344_add_timezone_to_user_options.rb
@@ -3,14 +3,12 @@
class AddTimezoneToUserOptions < ActiveRecord::Migration[6.0]
def up
add_column :user_options, :timezone, :string
- execute(
- <<-SQL
+ execute(<<-SQL)
UPDATE user_options
SET timezone = ucf.value
FROM user_custom_fields AS ucf
WHERE ucf.user_id = user_options.user_id AND ucf.name = 'timezone'
SQL
- )
end
def down
diff --git a/db/migrate/20191128222140_add_unique_index_to_developers.rb b/db/migrate/20191128222140_add_unique_index_to_developers.rb
index d839b157709..2c7e99df040 100644
--- a/db/migrate/20191128222140_add_unique_index_to_developers.rb
+++ b/db/migrate/20191128222140_add_unique_index_to_developers.rb
@@ -15,7 +15,7 @@ class AddUniqueIndexToDevelopers < ActiveRecord::Migration[6.0]
d1.id <> d2.id
SQL
- add_index :developers, %i(user_id), unique: true
+ add_index :developers, %i[user_id], unique: true
end
def down
diff --git a/db/migrate/20191129144706_drop_unused_google_instagram_auth_tables.rb b/db/migrate/20191129144706_drop_unused_google_instagram_auth_tables.rb
index f1b3df2e60a..f6df758fc1a 100644
--- a/db/migrate/20191129144706_drop_unused_google_instagram_auth_tables.rb
+++ b/db/migrate/20191129144706_drop_unused_google_instagram_auth_tables.rb
@@ -1,17 +1,12 @@
# frozen_string_literal: true
-require 'migration/table_dropper'
+require "migration/table_dropper"
class DropUnusedGoogleInstagramAuthTables < ActiveRecord::Migration[6.0]
- DROPPED_TABLES ||= %i{
- google_user_infos
- instagram_user_infos
- }
+ DROPPED_TABLES ||= %i[google_user_infos instagram_user_infos]
def up
- DROPPED_TABLES.each do |table|
- Migration::TableDropper.execute_drop(table)
- end
+ DROPPED_TABLES.each { |table| Migration::TableDropper.execute_drop(table) }
end
def down
diff --git a/db/migrate/20191205100434_create_standalone_bookmarks_table.rb b/db/migrate/20191205100434_create_standalone_bookmarks_table.rb
index 74c636a8815..10a5d75480c 100644
--- a/db/migrate/20191205100434_create_standalone_bookmarks_table.rb
+++ b/db/migrate/20191205100434_create_standalone_bookmarks_table.rb
@@ -13,7 +13,7 @@ class CreateStandaloneBookmarksTable < ActiveRecord::Migration[6.0]
t.timestamps
end
- add_index :bookmarks, [:user_id, :post_id], unique: true
+ add_index :bookmarks, %i[user_id post_id], unique: true
end
def down
diff --git a/db/migrate/20191211170000_add_hashed_api_key.rb b/db/migrate/20191211170000_add_hashed_api_key.rb
index 2811239c5dc..385d5f29be8 100644
--- a/db/migrate/20191211170000_add_hashed_api_key.rb
+++ b/db/migrate/20191211170000_add_hashed_api_key.rb
@@ -4,12 +4,10 @@ class AddHashedApiKey < ActiveRecord::Migration[6.0]
add_column(:api_keys, :key_hash, :string)
add_column(:api_keys, :truncated_key, :string)
- execute(
- <<~SQL
+ execute(<<~SQL)
UPDATE api_keys
SET truncated_key = LEFT(key, 4)
SQL
- )
batch_size = 500
begin
diff --git a/db/migrate/20191217035630_populate_topic_id_on_bookmarks.rb b/db/migrate/20191217035630_populate_topic_id_on_bookmarks.rb
index 1918c185ac2..c7d85193b9c 100644
--- a/db/migrate/20191217035630_populate_topic_id_on_bookmarks.rb
+++ b/db/migrate/20191217035630_populate_topic_id_on_bookmarks.rb
@@ -2,9 +2,10 @@
class PopulateTopicIdOnBookmarks < ActiveRecord::Migration[6.0]
def up
- Bookmark.where(topic_id: nil).includes(:post).find_each do |bookmark|
- bookmark.update_column(:topic_id, bookmark.post.topic_id)
- end
+ Bookmark
+ .where(topic_id: nil)
+ .includes(:post)
+ .find_each { |bookmark| bookmark.update_column(:topic_id, bookmark.post.topic_id) }
end
def down
diff --git a/db/migrate/20191219112000_remove_key_from_api_keys.rb b/db/migrate/20191219112000_remove_key_from_api_keys.rb
index 75e93d3c950..c9dcb70f171 100644
--- a/db/migrate/20191219112000_remove_key_from_api_keys.rb
+++ b/db/migrate/20191219112000_remove_key_from_api_keys.rb
@@ -1,13 +1,9 @@
# frozen_string_literal: true
class RemoveKeyFromApiKeys < ActiveRecord::Migration[6.0]
- DROPPED_COLUMNS ||= {
- api_keys: %i{key}
- }
+ DROPPED_COLUMNS ||= { api_keys: %i[key] }
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
diff --git a/db/migrate/20191230055237_add_access_control_columns_to_upload.rb b/db/migrate/20191230055237_add_access_control_columns_to_upload.rb
index 87f1a213efb..717da9b39f2 100644
--- a/db/migrate/20191230055237_add_access_control_columns_to_upload.rb
+++ b/db/migrate/20191230055237_add_access_control_columns_to_upload.rb
@@ -2,7 +2,13 @@
class AddAccessControlColumnsToUpload < ActiveRecord::Migration[6.0]
def up
- add_reference :uploads, :access_control_post, foreign_key: { to_table: :posts }, index: true, null: true
+ add_reference :uploads,
+ :access_control_post,
+ foreign_key: {
+ to_table: :posts,
+ },
+ index: true,
+ null: true
add_column :uploads, :original_sha1, :string, null: true
add_index :uploads, :original_sha1
end
diff --git a/db/migrate/20200117141138_update_post_reply_indexes.rb b/db/migrate/20200117141138_update_post_reply_indexes.rb
index 0ba728edcc7..12190d2a7a4 100644
--- a/db/migrate/20200117141138_update_post_reply_indexes.rb
+++ b/db/migrate/20200117141138_update_post_reply_indexes.rb
@@ -6,16 +6,16 @@ class UpdatePostReplyIndexes < ActiveRecord::Migration[6.0]
disable_ddl_transaction!
def up
- if !index_exists?(:post_replies, [:post_id, :reply_post_id])
- add_index :post_replies, [:post_id, :reply_post_id], unique: true, algorithm: :concurrently
+ if !index_exists?(:post_replies, %i[post_id reply_post_id])
+ add_index :post_replies, %i[post_id reply_post_id], unique: true, algorithm: :concurrently
end
if !index_exists?(:post_replies, [:reply_post_id])
add_index :post_replies, [:reply_post_id], algorithm: :concurrently
end
- if index_exists?(:post_replies, [:post_id, :reply_id])
- remove_index :post_replies, column: [:post_id, :reply_id], algorithm: :concurrently
+ if index_exists?(:post_replies, %i[post_id reply_id])
+ remove_index :post_replies, column: %i[post_id reply_id], algorithm: :concurrently
end
if index_exists?(:post_replies, [:reply_id])
diff --git a/db/migrate/20200120131338_drop_unused_columns.rb b/db/migrate/20200120131338_drop_unused_columns.rb
index 096f3ee4a6d..9e0cd64c712 100644
--- a/db/migrate/20200120131338_drop_unused_columns.rb
+++ b/db/migrate/20200120131338_drop_unused_columns.rb
@@ -2,19 +2,12 @@
class DropUnusedColumns < ActiveRecord::Migration[6.0]
DROPPED_COLUMNS ||= {
- post_replies: %i{
- reply_id
- },
- user_profiles: %i{
- card_background
- profile_background
- }
+ post_replies: %i[reply_id],
+ user_profiles: %i[card_background profile_background],
}
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
diff --git a/db/migrate/20200311135425_clear_approved_users_from_the_review_queue.rb b/db/migrate/20200311135425_clear_approved_users_from_the_review_queue.rb
index 349fea7c7b7..4f1e5002093 100644
--- a/db/migrate/20200311135425_clear_approved_users_from_the_review_queue.rb
+++ b/db/migrate/20200311135425_clear_approved_users_from_the_review_queue.rb
@@ -11,12 +11,12 @@ class ClearApprovedUsersFromTheReviewQueue < ActiveRecord::Migration[6.0]
SQL
system_user_id = Discourse::SYSTEM_USER_ID
- scores = reviewables.map do |id|
- "(#{id}, 1, #{Reviewable.statuses[:approved]}, #{system_user_id}, NOW(), NOW())"
- end
+ scores =
+ reviewables.map do |id|
+ "(#{id}, 1, #{Reviewable.statuses[:approved]}, #{system_user_id}, NOW(), NOW())"
+ end
- if scores.present?
- DB.exec <<~SQL
+ DB.exec <<~SQL if scores.present?
INSERT INTO reviewable_histories (
reviewable_id,
reviewable_history_type,
@@ -25,9 +25,8 @@ class ClearApprovedUsersFromTheReviewQueue < ActiveRecord::Migration[6.0]
created_at,
updated_at
)
- VALUES #{scores.join(',') << ';'}
+ VALUES #{scores.join(",") << ";"}
SQL
- end
end
def down
diff --git a/db/migrate/20200403100259_add_key_hash_to_user_api_key.rb b/db/migrate/20200403100259_add_key_hash_to_user_api_key.rb
index 138cf28b553..01f9abb4c0b 100644
--- a/db/migrate/20200403100259_add_key_hash_to_user_api_key.rb
+++ b/db/migrate/20200403100259_add_key_hash_to_user_api_key.rb
@@ -6,9 +6,10 @@ class AddKeyHashToUserApiKey < ActiveRecord::Migration[6.0]
batch_size = 500
loop do
- rows = DB
- .query("SELECT id, key FROM user_api_keys WHERE key_hash IS NULL LIMIT #{batch_size}")
- .map { |row| { id: row.id, key_hash: Digest::SHA256.hexdigest(row.key) } }
+ rows =
+ DB
+ .query("SELECT id, key FROM user_api_keys WHERE key_hash IS NULL LIMIT #{batch_size}")
+ .map { |row| { id: row.id, key_hash: Digest::SHA256.hexdigest(row.key) } }
break if rows.size == 0
diff --git a/db/migrate/20200408121312_remove_key_from_user_api_key.rb b/db/migrate/20200408121312_remove_key_from_user_api_key.rb
index a6147e5d584..e2b0602fb8f 100644
--- a/db/migrate/20200408121312_remove_key_from_user_api_key.rb
+++ b/db/migrate/20200408121312_remove_key_from_user_api_key.rb
@@ -1,14 +1,10 @@
# frozen_string_literal: true
class RemoveKeyFromUserApiKey < ActiveRecord::Migration[6.0]
- DROPPED_COLUMNS ||= {
- user_api_keys: %i{key}
- }
+ DROPPED_COLUMNS ||= { user_api_keys: %i[key] }
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
diff --git a/db/migrate/20200409033412_create_bookmarks_from_post_action_bookmarks.rb b/db/migrate/20200409033412_create_bookmarks_from_post_action_bookmarks.rb
index 57b1885e350..bae9cb2e6e2 100644
--- a/db/migrate/20200409033412_create_bookmarks_from_post_action_bookmarks.rb
+++ b/db/migrate/20200409033412_create_bookmarks_from_post_action_bookmarks.rb
@@ -9,8 +9,7 @@ class CreateBookmarksFromPostActionBookmarks < ActiveRecord::Migration[6.0]
# post action type id 1 is :bookmark. we do not need to OFFSET here for
# paging because the WHERE bookmarks.id IS NULL clause handles this effectively,
# because we do not get bookmarks back that have already been inserted
- post_action_bookmarks = DB.query(
- <<~SQL, type_id: 1
+ post_action_bookmarks = DB.query(<<~SQL, type_id: 1)
SELECT post_actions.id, post_actions.post_id, posts.topic_id, post_actions.user_id
FROM post_actions
INNER JOIN posts ON posts.id = post_actions.post_id
@@ -20,7 +19,6 @@ class CreateBookmarksFromPostActionBookmarks < ActiveRecord::Migration[6.0]
WHERE bookmarks.id IS NULL AND post_action_type_id = :type_id AND post_actions.deleted_at IS NULL AND posts.deleted_at IS NULL
LIMIT 2000
SQL
- )
break if post_action_bookmarks.count.zero?
post_action_bookmarks.each do |pab|
@@ -48,12 +46,10 @@ class CreateBookmarksFromPostActionBookmarks < ActiveRecord::Migration[6.0]
# the above LEFT JOIN but best to be safe knowing this
# won't blow up
#
- DB.exec(
- <<~SQL
+ DB.exec(<<~SQL)
INSERT INTO bookmarks (topic_id, post_id, user_id, created_at, updated_at)
VALUES #{bookmarks_to_create.join(",\n")}
ON CONFLICT DO NOTHING
SQL
- )
end
end
diff --git a/db/migrate/20200415140830_drop_automatic_membership_retroactive_from_group.rb b/db/migrate/20200415140830_drop_automatic_membership_retroactive_from_group.rb
index 4e7b779d6bf..23a740aa27d 100644
--- a/db/migrate/20200415140830_drop_automatic_membership_retroactive_from_group.rb
+++ b/db/migrate/20200415140830_drop_automatic_membership_retroactive_from_group.rb
@@ -1,16 +1,10 @@
# frozen_string_literal: true
class DropAutomaticMembershipRetroactiveFromGroup < ActiveRecord::Migration[6.0]
- DROPPED_COLUMNS ||= {
- groups: %i{
- automatic_membership_retroactive
- }
- }
+ DROPPED_COLUMNS ||= { groups: %i[automatic_membership_retroactive] }
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
diff --git a/db/migrate/20200417183143_add_created_at_to_badge_user.rb b/db/migrate/20200417183143_add_created_at_to_badge_user.rb
index bbfd6066e9f..ae7349d00a9 100644
--- a/db/migrate/20200417183143_add_created_at_to_badge_user.rb
+++ b/db/migrate/20200417183143_add_created_at_to_badge_user.rb
@@ -2,8 +2,8 @@
class AddCreatedAtToBadgeUser < ActiveRecord::Migration[6.0]
def up
add_column :user_badges, :created_at, :datetime, null: true
- execute 'UPDATE user_badges SET created_at = granted_at WHERE created_at IS NULL'
- change_column :user_badges, :created_at, :datetime, null: false, default: 'current_timestamp'
+ execute "UPDATE user_badges SET created_at = granted_at WHERE created_at IS NULL"
+ change_column :user_badges, :created_at, :datetime, null: false, default: "current_timestamp"
end
def down
diff --git a/db/migrate/20200428014005_correct_topic_user_bookmarked_boolean.rb b/db/migrate/20200428014005_correct_topic_user_bookmarked_boolean.rb
index 9d6f8ea0290..cc690f50a3d 100644
--- a/db/migrate/20200428014005_correct_topic_user_bookmarked_boolean.rb
+++ b/db/migrate/20200428014005_correct_topic_user_bookmarked_boolean.rb
@@ -4,20 +4,16 @@ class CorrectTopicUserBookmarkedBoolean < ActiveRecord::Migration[6.0]
def up
# if the relation exists then we set to bookmarked because
# at least 1 bookmark for the user + topic exists
- DB.exec(
- <<~SQL
+ DB.exec(<<~SQL)
UPDATE topic_users SET bookmarked = true
FROM bookmarks AS b
WHERE NOT topic_users.bookmarked AND topic_users.topic_id = b.topic_id AND topic_users.user_id = b.user_id
SQL
- )
- DB.exec(
- <<~SQL
+ DB.exec(<<~SQL)
UPDATE topic_users SET bookmarked = false
WHERE topic_users.bookmarked AND (SELECT COUNT(*) FROM bookmarks WHERE topic_id = topic_users.topic_id AND user_id = topic_users.user_id) = 0
SQL
- )
end
def down
diff --git a/db/migrate/20200428102014_add_bulk_invite_link_to_invites.rb b/db/migrate/20200428102014_add_bulk_invite_link_to_invites.rb
index 57636b6dcb4..855d469a11d 100644
--- a/db/migrate/20200428102014_add_bulk_invite_link_to_invites.rb
+++ b/db/migrate/20200428102014_add_bulk_invite_link_to_invites.rb
@@ -6,7 +6,8 @@ class AddBulkInviteLinkToInvites < ActiveRecord::Migration[6.0]
add_column :invites, :redemption_count, :integer, null: false, default: 0
add_column :invites, :expires_at, :datetime, null: true
- invite_expiry_days = DB.query_single("SELECT value FROM site_settings WHERE name = 'invite_expiry_days'").first
+ invite_expiry_days =
+ DB.query_single("SELECT value FROM site_settings WHERE name = 'invite_expiry_days'").first
invite_expiry_days = 30 if invite_expiry_days.blank?
execute <<~SQL
UPDATE invites SET expires_at = updated_at + INTERVAL '#{invite_expiry_days} days'
diff --git a/db/migrate/20200429095034_add_topic_thumbnail_information.rb b/db/migrate/20200429095034_add_topic_thumbnail_information.rb
index 3efb4c3a022..1de2f764a75 100644
--- a/db/migrate/20200429095034_add_topic_thumbnail_information.rb
+++ b/db/migrate/20200429095034_add_topic_thumbnail_information.rb
@@ -4,7 +4,6 @@ class AddTopicThumbnailInformation < ActiveRecord::Migration[6.0]
disable_ddl_transaction!
def up
-
# tables are huge ... avoid holding on to large number of locks by doing one at a time
execute <<~SQL
ALTER TABLE posts
@@ -36,7 +35,10 @@ class AddTopicThumbnailInformation < ActiveRecord::Migration[6.0]
t.integer :max_height, null: false
end
- add_index :topic_thumbnails, [:upload_id, :max_width, :max_height], name: :unique_topic_thumbnails, unique: true
+ add_index :topic_thumbnails,
+ %i[upload_id max_width max_height],
+ name: :unique_topic_thumbnails,
+ unique: true
end
end
diff --git a/db/migrate/20200430072846_create_invited_users.rb b/db/migrate/20200430072846_create_invited_users.rb
index fa3f843e607..5c7592e7f2e 100644
--- a/db/migrate/20200430072846_create_invited_users.rb
+++ b/db/migrate/20200430072846_create_invited_users.rb
@@ -10,6 +10,6 @@ class CreateInvitedUsers < ActiveRecord::Migration[6.0]
end
add_index :invited_users, :invite_id
- add_index :invited_users, [:user_id, :invite_id], unique: true, where: 'user_id IS NOT NULL'
+ add_index :invited_users, %i[user_id invite_id], unique: true, where: "user_id IS NOT NULL"
end
end
diff --git a/db/migrate/20200506044956_migrate_at_desktop_bookmark_reminders.rb b/db/migrate/20200506044956_migrate_at_desktop_bookmark_reminders.rb
index add607b31d9..8245ba5fe4b 100644
--- a/db/migrate/20200506044956_migrate_at_desktop_bookmark_reminders.rb
+++ b/db/migrate/20200506044956_migrate_at_desktop_bookmark_reminders.rb
@@ -3,12 +3,10 @@
class MigrateAtDesktopBookmarkReminders < ActiveRecord::Migration[6.0]
def up
# reminder_type 0 is at_desktop, which is no longer valid
- DB.exec(
- <<~SQL, now: Time.zone.now
+ DB.exec(<<~SQL, now: Time.zone.now)
UPDATE bookmarks SET reminder_type = NULL, reminder_at = NULL, updated_at = :now
WHERE reminder_type = 0
SQL
- )
end
def down
diff --git a/db/migrate/20200507234409_ensure_bookmark_delete_when_reminder_sent_not_null.rb b/db/migrate/20200507234409_ensure_bookmark_delete_when_reminder_sent_not_null.rb
index 5052675f969..483226578e1 100644
--- a/db/migrate/20200507234409_ensure_bookmark_delete_when_reminder_sent_not_null.rb
+++ b/db/migrate/20200507234409_ensure_bookmark_delete_when_reminder_sent_not_null.rb
@@ -2,7 +2,9 @@
class EnsureBookmarkDeleteWhenReminderSentNotNull < ActiveRecord::Migration[6.0]
def change
- DB.exec("UPDATE bookmarks SET delete_when_reminder_sent = false WHERE delete_when_reminder_sent IS NULL")
+ DB.exec(
+ "UPDATE bookmarks SET delete_when_reminder_sent = false WHERE delete_when_reminder_sent IS NULL",
+ )
change_column_null :bookmarks, :delete_when_reminder_sent, false
end
end
diff --git a/db/migrate/20200511043818_add_more_flair_columns_to_group.rb b/db/migrate/20200511043818_add_more_flair_columns_to_group.rb
index 70c1b530439..3d2098549a5 100644
--- a/db/migrate/20200511043818_add_more_flair_columns_to_group.rb
+++ b/db/migrate/20200511043818_add_more_flair_columns_to_group.rb
@@ -7,29 +7,23 @@ class AddMoreFlairColumnsToGroup < ActiveRecord::Migration[6.0]
reversible do |dir|
dir.up do
- DB.exec(
- <<~SQL
+ DB.exec(<<~SQL)
UPDATE groups SET flair_icon = REPLACE(REPLACE(flair_url, 'fas fa-', ''), ' fa-', '-')
WHERE flair_url LIKE 'fa%'
SQL
- )
- DB.exec(
- <<~SQL
+ DB.exec(<<~SQL)
UPDATE groups g1
SET flair_upload_id = u.id
FROM groups g2
INNER JOIN uploads u ON g2.flair_url ~ CONCAT('\/', u.sha1, '[\.\w]*')
WHERE g1.id = g2.id
SQL
- )
- DB.exec(
- <<~SQL
+ DB.exec(<<~SQL)
UPDATE groups SET flair_url = NULL
WHERE flair_icon IS NOT NULL OR flair_upload_id IS NOT NULL
SQL
- )
end
end
end
diff --git a/db/migrate/20200513185052_drop_topic_reply_count.rb b/db/migrate/20200513185052_drop_topic_reply_count.rb
index 5bae3435c6b..4b5a57f6f7d 100644
--- a/db/migrate/20200513185052_drop_topic_reply_count.rb
+++ b/db/migrate/20200513185052_drop_topic_reply_count.rb
@@ -1,16 +1,10 @@
# frozen_string_literal: true
class DropTopicReplyCount < ActiveRecord::Migration[6.0]
- DROPPED_COLUMNS ||= {
- user_stats: %i{
- topic_reply_count
- }
- }
+ DROPPED_COLUMNS ||= { user_stats: %i[topic_reply_count] }
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
diff --git a/db/migrate/20200517140915_update_deprecated_icon_names.rb b/db/migrate/20200517140915_update_deprecated_icon_names.rb
index 74c07f7c6ee..4655bbe23e2 100644
--- a/db/migrate/20200517140915_update_deprecated_icon_names.rb
+++ b/db/migrate/20200517140915_update_deprecated_icon_names.rb
@@ -10,7 +10,10 @@ class UpdateDeprecatedIconNames < ActiveRecord::Migration[6.0]
end
def migrate_value(dir)
- icons = File.open("#{Rails.root}/db/migrate/20200517140915_fa4_renames.json", "r:UTF-8") { |f| JSON.parse(f.read) }
+ icons =
+ File.open("#{Rails.root}/db/migrate/20200517140915_fa4_renames.json", "r:UTF-8") do |f|
+ JSON.parse(f.read)
+ end
icons.each do |key, value|
from = dir == "up" ? key : value
@@ -26,7 +29,6 @@ class UpdateDeprecatedIconNames < ActiveRecord::Migration[6.0]
SET flair_icon = '#{to}'
WHERE flair_icon = '#{from}' OR flair_icon = 'fa-#{from}'
SQL
-
end
end
end
diff --git a/db/migrate/20200524181959_add_default_list_filter_to_categories.rb b/db/migrate/20200524181959_add_default_list_filter_to_categories.rb
index 4c43b5ccd3a..1a90e907801 100644
--- a/db/migrate/20200524181959_add_default_list_filter_to_categories.rb
+++ b/db/migrate/20200524181959_add_default_list_filter_to_categories.rb
@@ -2,6 +2,6 @@
class AddDefaultListFilterToCategories < ActiveRecord::Migration[6.0]
def change
- add_column :categories, :default_list_filter, :string, limit: 20, default: 'all'
+ add_column :categories, :default_list_filter, :string, limit: 20, default: "all"
end
end
diff --git a/db/migrate/20200525072638_remove_none_tags.rb b/db/migrate/20200525072638_remove_none_tags.rb
index ed50eea490d..da52e651bf7 100644
--- a/db/migrate/20200525072638_remove_none_tags.rb
+++ b/db/migrate/20200525072638_remove_none_tags.rb
@@ -4,9 +4,13 @@ class RemoveNoneTags < ActiveRecord::Migration[6.0]
def up
none_tag_id = DB.query_single("SELECT id FROM tags WHERE lower(name) = 'none'").first
if none_tag_id.present?
- [:tag_users, :topic_tags, :category_tag_stats, :category_tags, :tag_group_memberships].each do |table_name|
- execute "DELETE FROM #{table_name} WHERE tag_id = #{none_tag_id}"
- end
+ %i[
+ tag_users
+ topic_tags
+ category_tag_stats
+ category_tags
+ tag_group_memberships
+ ].each { |table_name| execute "DELETE FROM #{table_name} WHERE tag_id = #{none_tag_id}" }
execute "DELETE FROM tags WHERE id = #{none_tag_id} OR target_tag_id = #{none_tag_id}"
end
end
diff --git a/db/migrate/20200601130900_correct_schema_discrepancies.rb b/db/migrate/20200601130900_correct_schema_discrepancies.rb
index 4d76e953525..882824e47b4 100644
--- a/db/migrate/20200601130900_correct_schema_discrepancies.rb
+++ b/db/migrate/20200601130900_correct_schema_discrepancies.rb
@@ -4,7 +4,7 @@ class CorrectSchemaDiscrepancies < ActiveRecord::Migration[6.0]
disable_ddl_transaction!
def up
- timestamp_columns = %w{
+ timestamp_columns = %w[
category_tag_groups.created_at
category_tag_groups.updated_at
category_tags.created_at
@@ -65,9 +65,9 @@ class CorrectSchemaDiscrepancies < ActiveRecord::Migration[6.0]
web_hook_events.updated_at
web_hooks.created_at
web_hooks.updated_at
- }
+ ]
- char_limit_columns = %w{
+ char_limit_columns = %w[
badge_groupings.name
badge_types.name
badges.icon
@@ -136,30 +136,25 @@ class CorrectSchemaDiscrepancies < ActiveRecord::Migration[6.0]
user_profiles.website
users.name
users.title
- }
+ ]
- float_default_columns = %w{
+ float_default_columns = %w[
top_topics.all_score
top_topics.daily_score
top_topics.monthly_score
top_topics.weekly_score
top_topics.yearly_score
- }
-
- other_default_columns = %w{
- categories.color
- topic_search_data.topic_id
- }
-
- lookup_sql = (
- timestamp_columns +
- char_limit_columns +
- float_default_columns +
- other_default_columns
- ).map do |ref|
- table, column = ref.split(".")
- "(table_name='#{table}' AND column_name='#{column}')"
- end.join(" OR ")
+ ]
+
+ other_default_columns = %w[categories.color topic_search_data.topic_id]
+
+ lookup_sql =
+ (timestamp_columns + char_limit_columns + float_default_columns + other_default_columns)
+ .map do |ref|
+ table, column = ref.split(".")
+ "(table_name='#{table}' AND column_name='#{column}')"
+ end
+ .join(" OR ")
raw_info = DB.query_hash <<~SQL
SELECT table_name, column_name, is_nullable, character_maximum_length, column_default
@@ -172,9 +167,7 @@ class CorrectSchemaDiscrepancies < ActiveRecord::Migration[6.0]
schema_hash = {}
- raw_info.each do |row|
- schema_hash["#{row["table_name"]}.#{row["column_name"]}"] = row
- end
+ raw_info.each { |row| schema_hash["#{row["table_name"]}.#{row["column_name"]}"] = row }
# In the past, rails changed the default behavior for timestamp columns
# This only affects older discourse installations
@@ -232,11 +225,9 @@ class CorrectSchemaDiscrepancies < ActiveRecord::Migration[6.0]
# Older sites have a default value like nextval('topic_search_data_topic_id_seq'::regclass)
# Modern sites do not. This is likely caused by another historical change in rails
- if schema_hash["topic_search_data.topic_id"]["column_default"] != nil
- DB.exec <<~SQL
+ DB.exec <<~SQL if schema_hash["topic_search_data.topic_id"]["column_default"] != nil
ALTER TABLE topic_search_data ALTER COLUMN topic_id SET DEFAULT NULL
SQL
- end
end
def down
diff --git a/db/migrate/20200602153813_migrate_invite_redeemed_data_to_invited_users.rb b/db/migrate/20200602153813_migrate_invite_redeemed_data_to_invited_users.rb
index 7f38286d4f9..5f7922536bb 100644
--- a/db/migrate/20200602153813_migrate_invite_redeemed_data_to_invited_users.rb
+++ b/db/migrate/20200602153813_migrate_invite_redeemed_data_to_invited_users.rb
@@ -1,10 +1,10 @@
# frozen_string_literal: true
-require 'migration/column_dropper'
+require "migration/column_dropper"
class MigrateInviteRedeemedDataToInvitedUsers < ActiveRecord::Migration[6.0]
def up
- %i{user_id redeemed_at}.each do |column|
+ %i[user_id redeemed_at].each do |column|
Migration::ColumnDropper.mark_readonly(:invites, column)
end
diff --git a/db/migrate/20200707154522_fix_topic_like_count.rb b/db/migrate/20200707154522_fix_topic_like_count.rb
index 95dd170792e..8bbb36678ca 100644
--- a/db/migrate/20200707154522_fix_topic_like_count.rb
+++ b/db/migrate/20200707154522_fix_topic_like_count.rb
@@ -2,7 +2,11 @@
class FixTopicLikeCount < ActiveRecord::Migration[6.0]
def up
- return if DB.query_single("SELECT * FROM site_settings WHERE name = 'enable_whispers' AND value = 't'").empty?
+ if DB.query_single(
+ "SELECT * FROM site_settings WHERE name = 'enable_whispers' AND value = 't'",
+ ).empty?
+ return
+ end
DB.exec(<<~SQL, whisper: Post.types[:whisper])
UPDATE topics SET like_count = tbl.like_count
diff --git a/db/migrate/20200708051009_cap_bookmark_name_at_100_characters.rb b/db/migrate/20200708051009_cap_bookmark_name_at_100_characters.rb
index 1428778531e..eb25419cf55 100644
--- a/db/migrate/20200708051009_cap_bookmark_name_at_100_characters.rb
+++ b/db/migrate/20200708051009_cap_bookmark_name_at_100_characters.rb
@@ -2,7 +2,9 @@
class CapBookmarkNameAt100Characters < ActiveRecord::Migration[6.0]
def up
- DB.exec("UPDATE bookmarks SET name = LEFT(name, 100) WHERE name IS NOT NULL AND name <> LEFT(name, 100)")
+ DB.exec(
+ "UPDATE bookmarks SET name = LEFT(name, 100) WHERE name IS NOT NULL AND name <> LEFT(name, 100)",
+ )
change_column :bookmarks, :name, :string, limit: 100
end
diff --git a/db/migrate/20200709032247_allowlist_and_blocklist_site_settings.rb b/db/migrate/20200709032247_allowlist_and_blocklist_site_settings.rb
index 7145c9fe818..c69e58f0e1d 100644
--- a/db/migrate/20200709032247_allowlist_and_blocklist_site_settings.rb
+++ b/db/migrate/20200709032247_allowlist_and_blocklist_site_settings.rb
@@ -2,22 +2,18 @@
class AllowlistAndBlocklistSiteSettings < ActiveRecord::Migration[6.0]
def up
- SiteSetting::ALLOWLIST_DEPRECATED_SITE_SETTINGS.each_pair do |old_key, new_key|
- DB.exec <<~SQL
+ SiteSetting::ALLOWLIST_DEPRECATED_SITE_SETTINGS.each_pair { |old_key, new_key| DB.exec <<~SQL }
INSERT INTO site_settings(name, data_type, value, created_at, updated_at)
SELECT '#{new_key}', data_type, value, created_at, updated_At
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
+ SiteSetting::ALLOWLIST_DEPRECATED_SITE_SETTINGS.each_pair { |_old_key, new_key| DB.exec <<~SQL }
DELETE FROM site_settings
WHERE name = '#{new_key}'
SQL
- end
end
end
diff --git a/db/migrate/20200717193118_create_allowed_pm_users.rb b/db/migrate/20200717193118_create_allowed_pm_users.rb
index 5c368eccf20..30e52f18fd3 100644
--- a/db/migrate/20200717193118_create_allowed_pm_users.rb
+++ b/db/migrate/20200717193118_create_allowed_pm_users.rb
@@ -7,7 +7,7 @@ class CreateAllowedPmUsers < ActiveRecord::Migration[6.0]
t.timestamps null: false
end
- add_index :allowed_pm_users, [:user_id, :allowed_pm_user_id], unique: true
- add_index :allowed_pm_users, [:allowed_pm_user_id, :user_id], unique: true
+ add_index :allowed_pm_users, %i[user_id allowed_pm_user_id], unique: true
+ add_index :allowed_pm_users, %i[allowed_pm_user_id user_id], unique: true
end
end
diff --git a/db/migrate/20200724060632_remove_deprecated_allowlist_settings.rb b/db/migrate/20200724060632_remove_deprecated_allowlist_settings.rb
index 38b87c9ac26..038c43d723b 100644
--- a/db/migrate/20200724060632_remove_deprecated_allowlist_settings.rb
+++ b/db/migrate/20200724060632_remove_deprecated_allowlist_settings.rb
@@ -2,22 +2,18 @@
class RemoveDeprecatedAllowlistSettings < ActiveRecord::Migration[6.0]
def up
- SiteSetting::ALLOWLIST_DEPRECATED_SITE_SETTINGS.each_pair do |old_key, _new_key|
- DB.exec <<~SQL
+ SiteSetting::ALLOWLIST_DEPRECATED_SITE_SETTINGS.each_pair { |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
+ SiteSetting::ALLOWLIST_DEPRECATED_SITE_SETTINGS.each_pair { |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/20200728000854_duplicate_allowed_paths_from_path_whitelist.rb b/db/migrate/20200728000854_duplicate_allowed_paths_from_path_whitelist.rb
index 17dd89960e5..5f8a1b5d287 100644
--- a/db/migrate/20200728000854_duplicate_allowed_paths_from_path_whitelist.rb
+++ b/db/migrate/20200728000854_duplicate_allowed_paths_from_path_whitelist.rb
@@ -7,14 +7,12 @@ class DuplicateAllowedPathsFromPathWhitelist < ActiveRecord::Migration[6.0]
end
if column_exists?(:embeddable_hosts, :path_whitelist)
- Migration::ColumnDropper.mark_readonly('embeddable_hosts', 'path_whitelist')
+ Migration::ColumnDropper.mark_readonly("embeddable_hosts", "path_whitelist")
- if column_exists?(:embeddable_hosts, :allowed_paths)
- DB.exec <<~SQL
+ DB.exec <<~SQL if column_exists?(:embeddable_hosts, :allowed_paths)
UPDATE embeddable_hosts
SET allowed_paths = path_whitelist
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
index 56771b4c075..1a85e38c8eb 100644
--- a/db/migrate/20200728004302_drop_path_whitelist_from_embeddable_hosts.rb
+++ b/db/migrate/20200728004302_drop_path_whitelist_from_embeddable_hosts.rb
@@ -1,14 +1,10 @@
# frozen_string_literal: true
class DropPathWhitelistFromEmbeddableHosts < ActiveRecord::Migration[6.0]
- DROPPED_COLUMNS ||= {
- embeddable_hosts: %i{path_whitelist}
- }
+ DROPPED_COLUMNS ||= { embeddable_hosts: %i[path_whitelist] }
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
diff --git a/db/migrate/20200730205554_create_group_default_tracking.rb b/db/migrate/20200730205554_create_group_default_tracking.rb
index 1a1ac25a992..fc727f7b71c 100644
--- a/db/migrate/20200730205554_create_group_default_tracking.rb
+++ b/db/migrate/20200730205554_create_group_default_tracking.rb
@@ -9,9 +9,9 @@ class CreateGroupDefaultTracking < ActiveRecord::Migration[6.0]
end
add_index :group_category_notification_defaults,
- [:group_id, :category_id],
- unique: true,
- name: :idx_group_category_notification_defaults_unique
+ %i[group_id category_id],
+ unique: true,
+ name: :idx_group_category_notification_defaults_unique
create_table :group_tag_notification_defaults do |t|
t.integer :group_id, null: false
@@ -20,8 +20,8 @@ class CreateGroupDefaultTracking < ActiveRecord::Migration[6.0]
end
add_index :group_tag_notification_defaults,
- [:group_id, :tag_id],
- unique: true,
- name: :idx_group_tag_notification_defaults_unique
+ %i[group_id tag_id],
+ unique: true,
+ name: :idx_group_tag_notification_defaults_unique
end
end
diff --git a/db/migrate/20200810194943_change_selectable_avatars_site_setting.rb b/db/migrate/20200810194943_change_selectable_avatars_site_setting.rb
index a7566150080..8e389843cbb 100644
--- a/db/migrate/20200810194943_change_selectable_avatars_site_setting.rb
+++ b/db/migrate/20200810194943_change_selectable_avatars_site_setting.rb
@@ -2,7 +2,8 @@
class ChangeSelectableAvatarsSiteSetting < ActiveRecord::Migration[6.0]
def up
- selectable_avatars = execute("SELECT value FROM site_settings WHERE name = 'selectable_avatars'")
+ selectable_avatars =
+ execute("SELECT value FROM site_settings WHERE name = 'selectable_avatars'")
return if selectable_avatars.cmd_tuples == 0
# Keep old site setting value as a backup
@@ -15,22 +16,28 @@ class ChangeSelectableAvatarsSiteSetting < ActiveRecord::Migration[6.0]
# Extract SHA1s from URLs and then use them for upload ID lookups
urls = []
sha1s = []
- selectable_avatars.first["value"].split("\n").each do |url|
- match = url.match(/(\/original\/\dX[\/\.\w]*\/(\h+)[\.\w]*)/)
- if match.present?
- urls << match[1]
- sha1s << match[2]
- else
- STDERR.puts "Could not extract a SHA1 from #{url}"
+ selectable_avatars.first["value"]
+ .split("\n")
+ .each do |url|
+ match = url.match(%r{(/original/\dX[/\.\w]*/(\h+)[\.\w]*)})
+ if match.present?
+ urls << match[1]
+ sha1s << match[2]
+ else
+ STDERR.puts "Could not extract a SHA1 from #{url}"
+ end
end
- end
# Ensure at least one URL or SHA1 exists so the query below can be valid
return if urls.size == 0 && sha1s.size == 0
uploads_query = []
- uploads_query << "url IN (#{urls.map { |url| ActiveRecord::Base.connection.quote(url) }.join(',')})" if urls.size > 0
- uploads_query << "sha1 IN (#{sha1s.map { |sha1| ActiveRecord::Base.connection.quote(sha1) }.join(',')})" if sha1s.size > 0
+ if urls.size > 0
+ uploads_query << "url IN (#{urls.map { |url| ActiveRecord::Base.connection.quote(url) }.join(",")})"
+ end
+ if sha1s.size > 0
+ uploads_query << "sha1 IN (#{sha1s.map { |sha1| ActiveRecord::Base.connection.quote(sha1) }.join(",")})"
+ end
uploads_query = "SELECT DISTINCT id FROM uploads WHERE #{uploads_query.join(" OR ")}"
upload_ids = execute(uploads_query).map { |row| row["id"] }
@@ -46,6 +53,8 @@ class ChangeSelectableAvatarsSiteSetting < ActiveRecord::Migration[6.0]
def down
execute("DELETE FROM site_settings WHERE name = 'selectable_avatars'")
- execute("UPDATE site_settings SET name = 'selectable_avatars' WHERE name = 'selectable_avatars_urls'")
+ execute(
+ "UPDATE site_settings SET name = 'selectable_avatars' WHERE name = 'selectable_avatars_urls'",
+ )
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
index cab2c49ebf4..1d42b1dec63 100644
--- a/db/migrate/20200818084329_update_private_message_on_post_search_data.rb
+++ b/db/migrate/20200818084329_update_private_message_on_post_search_data.rb
@@ -5,7 +5,6 @@ class UpdatePrivateMessageOnPostSearchData < ActiveRecord::Migration[6.0]
disable_ddl_transaction!
def update_private_message_flag
-
sql = <<~SQL
UPDATE post_search_data
SET private_message = X.private_message
diff --git a/db/migrate/20200819030609_migrate_user_topic_timers_to_bookmark_reminders.rb b/db/migrate/20200819030609_migrate_user_topic_timers_to_bookmark_reminders.rb
index 2c9ddbc6b65..8699051eda7 100644
--- a/db/migrate/20200819030609_migrate_user_topic_timers_to_bookmark_reminders.rb
+++ b/db/migrate/20200819030609_migrate_user_topic_timers_to_bookmark_reminders.rb
@@ -15,9 +15,8 @@ class MigrateUserTopicTimersToBookmarkReminders < ActiveRecord::Migration[6.0]
return if topic_timers_to_migrate.empty?
- topic_timer_tuples = topic_timers_to_migrate.map do |tt|
- "(#{tt.user_id}, #{tt.topic_id})"
- end.join(", ")
+ topic_timer_tuples =
+ topic_timers_to_migrate.map { |tt| "(#{tt.user_id}, #{tt.topic_id})" }.join(", ")
existing_bookmarks = DB.query(<<~SQL)
SELECT bookmarks.id, reminder_at, reminder_type,
@@ -29,12 +28,12 @@ class MigrateUserTopicTimersToBookmarkReminders < ActiveRecord::Migration[6.0]
new_bookmarks = []
topic_timers_to_migrate.each do |tt|
- bookmark = existing_bookmarks.find do |bm|
-
- # we only care about existing topic-level bookmarks here
- # because topic timers are (funnily enough) topic-level
- bm.topic_id == tt.topic_id && bm.user_id == tt.user_id && bm.post_number == 1
- end
+ bookmark =
+ existing_bookmarks.find do |bm|
+ # we only care about existing topic-level bookmarks here
+ # because topic timers are (funnily enough) topic-level
+ bm.topic_id == tt.topic_id && bm.user_id == tt.user_id && bm.post_number == 1
+ end
if !bookmark
# create one
@@ -45,7 +44,7 @@ class MigrateUserTopicTimersToBookmarkReminders < ActiveRecord::Migration[6.0]
DB.exec(
"UPDATE bookmarks SET reminder_at = :reminder_at, reminder_type = 6 WHERE id = :bookmark_id",
reminder_at: tt.execute_at,
- bookmark_id: bookmark.id
+ bookmark_id: bookmark.id,
)
end
@@ -69,7 +68,7 @@ class MigrateUserTopicTimersToBookmarkReminders < ActiveRecord::Migration[6.0]
"UPDATE topic_timers SET deleted_at = :deleted_at, deleted_by_id = :deleted_by WHERE ID IN (:ids)",
ids: topic_timers_to_migrate_ids,
deleted_at: Time.zone.now,
- deleted_by: Discourse.system_user
+ deleted_by: Discourse.system_user,
)
end
diff --git a/db/migrate/20200820174703_add_partial_target_id_index_to_reviewables.rb b/db/migrate/20200820174703_add_partial_target_id_index_to_reviewables.rb
index 55d2bd81ac6..f2148411a09 100644
--- a/db/migrate/20200820174703_add_partial_target_id_index_to_reviewables.rb
+++ b/db/migrate/20200820174703_add_partial_target_id_index_to_reviewables.rb
@@ -4,6 +4,10 @@ class AddPartialTargetIdIndexToReviewables < ActiveRecord::Migration[6.0]
disable_ddl_transaction!
def change
- add_index :reviewables, [:target_id], where: "target_type = 'Post'", algorithm: :concurrently, name: "index_reviewables_on_target_id_where_post_type_eq_post"
+ add_index :reviewables,
+ [:target_id],
+ where: "target_type = 'Post'",
+ algorithm: :concurrently,
+ name: "index_reviewables_on_target_id_where_post_type_eq_post"
end
end
diff --git a/db/migrate/20200902054531_add_first_unread_pm_a_to_group_user.rb b/db/migrate/20200902054531_add_first_unread_pm_a_to_group_user.rb
index 8cfb624a113..89e0fbdb56a 100644
--- a/db/migrate/20200902054531_add_first_unread_pm_a_to_group_user.rb
+++ b/db/migrate/20200902054531_add_first_unread_pm_a_to_group_user.rb
@@ -2,7 +2,11 @@
class AddFirstUnreadPmAToGroupUser < ActiveRecord::Migration[6.0]
def up
- add_column :group_users, :first_unread_pm_at, :datetime, null: false, default: -> { 'CURRENT_TIMESTAMP' }
+ add_column :group_users,
+ :first_unread_pm_at,
+ :datetime,
+ null: false,
+ default: -> { "CURRENT_TIMESTAMP" }
execute <<~SQL
UPDATE group_users gu
diff --git a/db/migrate/20200902082203_add_first_unread_pm_at_to_user_stats.rb b/db/migrate/20200902082203_add_first_unread_pm_at_to_user_stats.rb
index 6f4c8e812ac..f7cb270419b 100644
--- a/db/migrate/20200902082203_add_first_unread_pm_at_to_user_stats.rb
+++ b/db/migrate/20200902082203_add_first_unread_pm_at_to_user_stats.rb
@@ -2,7 +2,11 @@
class AddFirstUnreadPmAtToUserStats < ActiveRecord::Migration[6.0]
def up
- add_column :user_stats, :first_unread_pm_at, :datetime, null: false, default: -> { 'CURRENT_TIMESTAMP' }
+ add_column :user_stats,
+ :first_unread_pm_at,
+ :datetime,
+ null: false,
+ default: -> { "CURRENT_TIMESTAMP" }
execute <<~SQL
UPDATE user_stats us
diff --git a/db/migrate/20200910051633_change_uploads_verified_to_integer.rb b/db/migrate/20200910051633_change_uploads_verified_to_integer.rb
index 785817b966f..18c19ee1e03 100644
--- a/db/migrate/20200910051633_change_uploads_verified_to_integer.rb
+++ b/db/migrate/20200910051633_change_uploads_verified_to_integer.rb
@@ -5,15 +5,13 @@ class ChangeUploadsVerifiedToInteger < ActiveRecord::Migration[6.0]
add_column :uploads, :verification_status, :integer, null: false, default: 1
Migration::ColumnDropper.mark_readonly(:uploads, :verified)
- DB.exec(
- <<~SQL
+ DB.exec(<<~SQL)
UPDATE uploads SET verification_status = CASE WHEN
verified THEN 2
WHEN NOT verified THEN 3
ELSE 1
END
SQL
- )
end
def down
diff --git a/db/migrate/20200916085541_create_user_ip_address_histories.rb b/db/migrate/20200916085541_create_user_ip_address_histories.rb
index d9d50b8aede..908fd414cc5 100644
--- a/db/migrate/20200916085541_create_user_ip_address_histories.rb
+++ b/db/migrate/20200916085541_create_user_ip_address_histories.rb
@@ -9,7 +9,7 @@ class CreateUserIpAddressHistories < ActiveRecord::Migration[6.0]
t.timestamps
end
- add_index :user_ip_address_histories, [:user_id, :ip_address], unique: true
+ add_index :user_ip_address_histories, %i[user_id ip_address], unique: true
end
def down
diff --git a/db/migrate/20201006021020_add_requested_by_to_email_change_request.rb b/db/migrate/20201006021020_add_requested_by_to_email_change_request.rb
index 6753a189757..8a76deba1d7 100644
--- a/db/migrate/20201006021020_add_requested_by_to_email_change_request.rb
+++ b/db/migrate/20201006021020_add_requested_by_to_email_change_request.rb
@@ -4,7 +4,9 @@ class AddRequestedByToEmailChangeRequest < ActiveRecord::Migration[6.0]
def up
add_column :email_change_requests, :requested_by_user_id, :integer, null: true
- DB.exec("CREATE INDEX IF NOT EXISTS idx_email_change_requests_on_requested_by ON email_change_requests(requested_by_user_id)")
+ DB.exec(
+ "CREATE INDEX IF NOT EXISTS idx_email_change_requests_on_requested_by ON email_change_requests(requested_by_user_id)",
+ )
end
def down
diff --git a/db/migrate/20201027110546_create_linked_topics.rb b/db/migrate/20201027110546_create_linked_topics.rb
index 0f3c8497d62..162e623a1c1 100644
--- a/db/migrate/20201027110546_create_linked_topics.rb
+++ b/db/migrate/20201027110546_create_linked_topics.rb
@@ -10,7 +10,7 @@ class CreateLinkedTopics < ActiveRecord::Migration[6.0]
t.timestamps
end
- add_index :linked_topics, [:topic_id, :original_topic_id], unique: true
- add_index :linked_topics, [:topic_id, :sequence], unique: true
+ add_index :linked_topics, %i[topic_id original_topic_id], unique: true
+ add_index :linked_topics, %i[topic_id sequence], unique: true
end
end
diff --git a/db/migrate/20201105190351_move_post_notices_to_json.rb b/db/migrate/20201105190351_move_post_notices_to_json.rb
index 82322ab7b66..b586cb64067 100644
--- a/db/migrate/20201105190351_move_post_notices_to_json.rb
+++ b/db/migrate/20201105190351_move_post_notices_to_json.rb
@@ -21,7 +21,11 @@ class MovePostNoticesToJson < ActiveRecord::Migration[6.0]
execute "DELETE FROM post_custom_fields WHERE name = 'notice_type' OR name = 'notice_args'"
- add_index :post_custom_fields, :post_id, unique: true, name: "index_post_custom_fields_on_notice", where: "name = 'notice'"
+ add_index :post_custom_fields,
+ :post_id,
+ unique: true,
+ name: "index_post_custom_fields_on_notice",
+ where: "name = 'notice'"
remove_index :post_custom_fields, name: "index_post_custom_fields_on_notice_type"
remove_index :post_custom_fields, name: "index_post_custom_fields_on_notice_args"
@@ -44,8 +48,16 @@ class MovePostNoticesToJson < ActiveRecord::Migration[6.0]
execute "DELETE FROM post_custom_fields WHERE name = 'notice'"
- add_index :post_custom_fields, :post_id, unique: true, name: "index_post_custom_fields_on_notice_type", where: "name = 'notice_type'"
- add_index :post_custom_fields, :post_id, unique: true, name: "index_post_custom_fields_on_notice_args", where: "name = 'notice_args'"
+ add_index :post_custom_fields,
+ :post_id,
+ unique: true,
+ name: "index_post_custom_fields_on_notice_type",
+ where: "name = 'notice_type'"
+ add_index :post_custom_fields,
+ :post_id,
+ unique: true,
+ name: "index_post_custom_fields_on_notice_args",
+ where: "name = 'notice_args'"
remove_index :index_post_custom_fields_on_notice
end
diff --git a/db/migrate/20201109170951_migrate_github_user_infos.rb b/db/migrate/20201109170951_migrate_github_user_infos.rb
index b93d9a4d4b5..5bab9989b63 100644
--- a/db/migrate/20201109170951_migrate_github_user_infos.rb
+++ b/db/migrate/20201109170951_migrate_github_user_infos.rb
@@ -29,14 +29,12 @@ class MigrateGithubUserInfos < ActiveRecord::Migration[6.0]
FROM github_user_infos
SQL
- if maintain_ids
- execute <<~SQL
+ execute <<~SQL if maintain_ids
SELECT setval(
pg_get_serial_sequence('user_associated_accounts', 'id'),
(select greatest(max(id), 1) from user_associated_accounts)
);
SQL
- end
end
def down
diff --git a/db/migrate/20201110110952_drop_github_user_infos.rb b/db/migrate/20201110110952_drop_github_user_infos.rb
index 7fbbb78b95e..275daeb035c 100644
--- a/db/migrate/20201110110952_drop_github_user_infos.rb
+++ b/db/migrate/20201110110952_drop_github_user_infos.rb
@@ -1,14 +1,12 @@
# frozen_string_literal: true
-require 'migration/table_dropper'
+require "migration/table_dropper"
class DropGithubUserInfos < ActiveRecord::Migration[6.0]
- DROPPED_TABLES ||= %i{ github_user_infos }
+ DROPPED_TABLES ||= %i[github_user_infos]
def up
- DROPPED_TABLES.each do |table|
- Migration::TableDropper.execute_drop(table)
- end
+ DROPPED_TABLES.each { |table| Migration::TableDropper.execute_drop(table) }
end
def down
diff --git a/db/migrate/20201117212328_set_category_slug_to_lower.rb b/db/migrate/20201117212328_set_category_slug_to_lower.rb
index 8d7d275645b..924de41bccd 100644
--- a/db/migrate/20201117212328_set_category_slug_to_lower.rb
+++ b/db/migrate/20201117212328_set_category_slug_to_lower.rb
@@ -2,7 +2,7 @@
class SetCategorySlugToLower < ActiveRecord::Migration[6.0]
def up
- remove_index(:categories, name: 'unique_index_categories_on_slug')
+ remove_index(:categories, name: "unique_index_categories_on_slug")
categories = DB.query("SELECT id, name, slug, parent_category_id FROM categories")
old_slugs = categories.map { |c| [c.id, c.slug] }.to_h
@@ -10,23 +10,26 @@ class SetCategorySlugToLower < ActiveRecord::Migration[6.0]
# Resolve duplicate tags by replacing mixed case slugs with new ones
# extracted from category names
- slugs = categories
- .filter { |category| category.slug.present? }
- .group_by { |category| [category.parent_category_id, category.slug.downcase] }
- .map { |slug, cats| [slug, cats.size] }
- .to_h
+ slugs =
+ categories
+ .filter { |category| category.slug.present? }
+ .group_by { |category| [category.parent_category_id, category.slug.downcase] }
+ .map { |slug, cats| [slug, cats.size] }
+ .to_h
categories.each do |category|
old_parent_and_slug = [category.parent_category_id, category.slug.downcase]
- next if category.slug.blank? ||
- category.slug == category.slug.downcase ||
- slugs[old_parent_and_slug] <= 1
+ if category.slug.blank? || category.slug == category.slug.downcase ||
+ slugs[old_parent_and_slug] <= 1
+ next
+ end
- new_slug = category.name.parameterize.tr("_", "-").squeeze('-').gsub(/\A-+|-+\z/, '')[0..255]
- new_slug = '' if (new_slug =~ /[^\d]/).blank?
+ new_slug = category.name.parameterize.tr("_", "-").squeeze("-").gsub(/\A-+|-+\z/, "")[0..255]
+ new_slug = "" if (new_slug =~ /[^\d]/).blank?
new_parent_and_slug = [category.parent_category_id, new_slug]
- next if new_slug.blank? ||
- (slugs[new_parent_and_slug].present? && slugs[new_parent_and_slug] > 0)
+ if new_slug.blank? || (slugs[new_parent_and_slug].present? && slugs[new_parent_and_slug] > 0)
+ next
+ end
updates[category.id] = category.slug = new_slug
slugs[old_parent_and_slug] -= 1
@@ -34,52 +37,52 @@ class SetCategorySlugToLower < ActiveRecord::Migration[6.0]
end
# Reset left conflicting slugs
- slugs = categories
- .filter { |category| category.slug.present? }
- .group_by { |category| [category.parent_category_id, category.slug.downcase] }
- .map { |slug, cats| [slug, cats.size] }
- .to_h
+ slugs =
+ categories
+ .filter { |category| category.slug.present? }
+ .group_by { |category| [category.parent_category_id, category.slug.downcase] }
+ .map { |slug, cats| [slug, cats.size] }
+ .to_h
categories.each do |category|
old_parent_and_slug = [category.parent_category_id, category.slug.downcase]
- next if category.slug.blank? ||
- category.slug == category.slug.downcase ||
- slugs[old_parent_and_slug] <= 1
+ if category.slug.blank? || category.slug == category.slug.downcase ||
+ slugs[old_parent_and_slug] <= 1
+ next
+ end
- updates[category.id] = category.slug = ''
+ updates[category.id] = category.slug = ""
slugs[old_parent_and_slug] -= 1
end
# Update all category slugs
- updates.each do |id, slug|
- execute <<~SQL
+ updates.each { |id, slug| execute <<~SQL }
UPDATE categories
SET slug = '#{PG::Connection.escape_string(slug)}'
WHERE id = #{id} -- #{PG::Connection.escape_string(old_slugs[id])}
SQL
- end
# Ensure all slugs are lowercase
execute "UPDATE categories SET slug = LOWER(slug)"
add_index(
:categories,
- 'COALESCE(parent_category_id, -1), LOWER(slug)',
- name: 'unique_index_categories_on_slug',
+ "COALESCE(parent_category_id, -1), LOWER(slug)",
+ name: "unique_index_categories_on_slug",
where: "slug != ''",
- unique: true
+ unique: true,
)
end
def down
- remove_index(:categories, name: 'unique_index_categories_on_slug')
+ remove_index(:categories, name: "unique_index_categories_on_slug")
add_index(
:categories,
- 'COALESCE(parent_category_id, -1), slug',
- name: 'unique_index_categories_on_slug',
+ "COALESCE(parent_category_id, -1), slug",
+ name: "unique_index_categories_on_slug",
where: "slug != ''",
- unique: true
+ unique: true,
)
end
end
diff --git a/db/migrate/20210125100452_migrate_search_data_after_default_locale_rename.rb b/db/migrate/20210125100452_migrate_search_data_after_default_locale_rename.rb
index 5d3f6e6d010..30b79f83944 100644
--- a/db/migrate/20210125100452_migrate_search_data_after_default_locale_rename.rb
+++ b/db/migrate/20210125100452_migrate_search_data_after_default_locale_rename.rb
@@ -4,7 +4,7 @@ class MigrateSearchDataAfterDefaultLocaleRename < ActiveRecord::Migration[6.0]
disable_ddl_transaction!
def up
- %w{category tag topic user}.each { |model| fix_search_data(model) }
+ %w[category tag topic user].each { |model| fix_search_data(model) }
end
def down
diff --git a/db/migrate/20210131221311_create_dismissed_topic_users_table.rb b/db/migrate/20210131221311_create_dismissed_topic_users_table.rb
index 699e05deedb..d0a9e45cfe5 100644
--- a/db/migrate/20210131221311_create_dismissed_topic_users_table.rb
+++ b/db/migrate/20210131221311_create_dismissed_topic_users_table.rb
@@ -7,6 +7,6 @@ class CreateDismissedTopicUsersTable < ActiveRecord::Migration[6.0]
t.integer :topic_id
t.datetime :created_at
end
- add_index :dismissed_topic_users, %i(user_id topic_id), unique: true
+ add_index :dismissed_topic_users, %i[user_id topic_id], unique: true
end
end
diff --git a/db/migrate/20210201034048_move_category_last_seen_at_to_new_table.rb b/db/migrate/20210201034048_move_category_last_seen_at_to_new_table.rb
index 2e61a42aa76..7221b3542cf 100644
--- a/db/migrate/20210201034048_move_category_last_seen_at_to_new_table.rb
+++ b/db/migrate/20210201034048_move_category_last_seen_at_to_new_table.rb
@@ -21,13 +21,16 @@ class MoveCategoryLastSeenAtToNewTable < ActiveRecord::Migration[6.0]
ORDER BY topics.created_at DESC
LIMIT :max_new_topics
SQL
- sql = DB.sql_fragment(sql,
- now: DateTime.now,
- last_visit: User::NewTopicDuration::LAST_VISIT,
- always: User::NewTopicDuration::ALWAYS,
- default_duration: SiteSetting.default_other_new_topic_duration_minutes,
- min_date: Time.at(SiteSetting.min_new_topics_time).to_datetime,
- max_new_topics: SiteSetting.max_new_topics)
+ sql =
+ DB.sql_fragment(
+ sql,
+ now: DateTime.now,
+ last_visit: User::NewTopicDuration::LAST_VISIT,
+ always: User::NewTopicDuration::ALWAYS,
+ default_duration: SiteSetting.default_other_new_topic_duration_minutes,
+ min_date: Time.at(SiteSetting.min_new_topics_time).to_datetime,
+ max_new_topics: SiteSetting.max_new_topics,
+ )
DB.exec(sql)
end
diff --git a/db/migrate/20210203031628_add_duration_minutes_to_topic_timer.rb b/db/migrate/20210203031628_add_duration_minutes_to_topic_timer.rb
index 3df0d3ad089..02ae77d0e00 100644
--- a/db/migrate/20210203031628_add_duration_minutes_to_topic_timer.rb
+++ b/db/migrate/20210203031628_add_duration_minutes_to_topic_timer.rb
@@ -6,8 +6,12 @@ class AddDurationMinutesToTopicTimer < ActiveRecord::Migration[6.0]
# 7 is delete_replies type, this duration is measured in days, the other
# duration is measured in hours
- DB.exec("UPDATE topic_timers SET duration_minutes = (duration * 60 * 24) WHERE duration_minutes != duration AND status_type = 7 AND duration IS NOT NULL")
- DB.exec("UPDATE topic_timers SET duration_minutes = (duration * 60) WHERE duration_minutes != duration AND status_type != 7 AND duration IS NOT NULL")
+ DB.exec(
+ "UPDATE topic_timers SET duration_minutes = (duration * 60 * 24) WHERE duration_minutes != duration AND status_type = 7 AND duration IS NOT NULL",
+ )
+ DB.exec(
+ "UPDATE topic_timers SET duration_minutes = (duration * 60) WHERE duration_minutes != duration AND status_type != 7 AND duration IS NOT NULL",
+ )
end
def down
diff --git a/db/migrate/20210204135429_rename_sso_site_settings.rb b/db/migrate/20210204135429_rename_sso_site_settings.rb
index a793e9fb807..2d2ef12072a 100644
--- a/db/migrate/20210204135429_rename_sso_site_settings.rb
+++ b/db/migrate/20210204135429_rename_sso_site_settings.rb
@@ -2,39 +2,37 @@
class RenameSsoSiteSettings < ActiveRecord::Migration[6.0]
RENAME_SETTINGS = [
- ['enable_sso', 'enable_discourse_connect'],
- ['sso_allows_all_return_paths', 'discourse_connect_allows_all_return_paths'],
- ['enable_sso_provider', 'enable_discourse_connect_provider'],
- ['verbose_sso_logging', 'verbose_discourse_connect_logging'],
- ['sso_url', 'discourse_connect_url'],
- ['sso_secret', 'discourse_connect_secret'],
- ['sso_provider_secrets', 'discourse_connect_provider_secrets'],
- ['sso_overrides_groups', 'discourse_connect_overrides_groups'],
- ['sso_overrides_bio', 'discourse_connect_overrides_bio'],
- ['sso_overrides_email', 'auth_overrides_email'],
- ['sso_overrides_username', 'auth_overrides_username'],
- ['sso_overrides_name', 'auth_overrides_name'],
- ['sso_overrides_avatar', 'discourse_connect_overrides_avatar'],
- ['sso_overrides_profile_background', 'discourse_connect_overrides_profile_background'],
- ['sso_overrides_location', 'discourse_connect_overrides_location'],
- ['sso_overrides_website', 'discourse_connect_overrides_website'],
- ['sso_overrides_card_background', 'discourse_connect_overrides_card_background'],
- ['external_auth_skip_create_confirm', 'auth_skip_create_confirm'],
- ['external_auth_immediately', 'auth_immediately']
+ %w[enable_sso enable_discourse_connect],
+ %w[sso_allows_all_return_paths discourse_connect_allows_all_return_paths],
+ %w[enable_sso_provider enable_discourse_connect_provider],
+ %w[verbose_sso_logging verbose_discourse_connect_logging],
+ %w[sso_url discourse_connect_url],
+ %w[sso_secret discourse_connect_secret],
+ %w[sso_provider_secrets discourse_connect_provider_secrets],
+ %w[sso_overrides_groups discourse_connect_overrides_groups],
+ %w[sso_overrides_bio discourse_connect_overrides_bio],
+ %w[sso_overrides_email auth_overrides_email],
+ %w[sso_overrides_username auth_overrides_username],
+ %w[sso_overrides_name auth_overrides_name],
+ %w[sso_overrides_avatar discourse_connect_overrides_avatar],
+ %w[sso_overrides_profile_background discourse_connect_overrides_profile_background],
+ %w[sso_overrides_location discourse_connect_overrides_location],
+ %w[sso_overrides_website discourse_connect_overrides_website],
+ %w[sso_overrides_card_background discourse_connect_overrides_card_background],
+ %w[external_auth_skip_create_confirm auth_skip_create_confirm],
+ %w[external_auth_immediately auth_immediately],
]
def up
# Copying the rows so that things keep working during deploy
# They will be dropped in post_migrate/20210219171329_drop_old_sso_site_settings
- RENAME_SETTINGS.each do |old_name, new_name|
- execute <<~SQL
+ RENAME_SETTINGS.each { |old_name, new_name| execute <<~SQL }
INSERT INTO site_settings (name, data_type, value, created_at, updated_at)
SELECT '#{new_name}', data_type, value, created_at, updated_at
FROM site_settings
WHERE name = '#{old_name}'
SQL
- end
end
def down
diff --git a/db/migrate/20210207232853_fix_topic_timer_duration_minutes.rb b/db/migrate/20210207232853_fix_topic_timer_duration_minutes.rb
index 22ecc3094f5..14baafee7cd 100644
--- a/db/migrate/20210207232853_fix_topic_timer_duration_minutes.rb
+++ b/db/migrate/20210207232853_fix_topic_timer_duration_minutes.rb
@@ -4,8 +4,12 @@ class FixTopicTimerDurationMinutes < ActiveRecord::Migration[6.0]
DB.exec("DELETE FROM topic_timers WHERE status_type = 7 AND duration > 20 * 365")
DB.exec("DELETE FROM topic_timers WHERE status_type != 7 AND duration > 20 * 365 * 24")
- DB.exec("UPDATE topic_timers SET duration_minutes = (duration * 60 * 24) WHERE duration_minutes IS NULL AND status_type = 7 AND duration IS NOT NULL")
- DB.exec("UPDATE topic_timers SET duration_minutes = (duration * 60) WHERE duration_minutes IS NULL AND status_type != 7 AND duration IS NOT NULL")
+ DB.exec(
+ "UPDATE topic_timers SET duration_minutes = (duration * 60 * 24) WHERE duration_minutes IS NULL AND status_type = 7 AND duration IS NOT NULL",
+ )
+ DB.exec(
+ "UPDATE topic_timers SET duration_minutes = (duration * 60) WHERE duration_minutes IS NULL AND status_type != 7 AND duration IS NOT NULL",
+ )
end
def down
diff --git a/db/migrate/20210215231312_fix_group_flair_avatar_upload_security_and_acls.rb b/db/migrate/20210215231312_fix_group_flair_avatar_upload_security_and_acls.rb
index 3232bacb6fb..0eae24bae28 100644
--- a/db/migrate/20210215231312_fix_group_flair_avatar_upload_security_and_acls.rb
+++ b/db/migrate/20210215231312_fix_group_flair_avatar_upload_security_and_acls.rb
@@ -4,12 +4,11 @@ class FixGroupFlairAvatarUploadSecurityAndAcls < ActiveRecord::Migration[6.0]
disable_ddl_transaction!
def up
- upload_ids = DB.query_single(<<~SQL
+ upload_ids = DB.query_single(<<~SQL)
SELECT flair_upload_id
FROM groups
WHERE flair_upload_id IS NOT NULL
SQL
- )
if upload_ids.any?
reason = "group_flair fixup migration"
@@ -19,7 +18,8 @@ class FixGroupFlairAvatarUploadSecurityAndAcls < ActiveRecord::Migration[6.0]
SQL
if Discourse.store.external?
- uploads = Upload.where(id: upload_ids, secure: false).where("updated_at = security_last_changed_at")
+ uploads =
+ Upload.where(id: upload_ids, secure: false).where("updated_at = security_last_changed_at")
uploads.each do |upload|
Discourse.store.update_upload_ACL(upload)
upload.touch
diff --git a/db/migrate/20210218022739_move_new_since_to_new_table_again.rb b/db/migrate/20210218022739_move_new_since_to_new_table_again.rb
index f468d09ff71..bc102f5c760 100644
--- a/db/migrate/20210218022739_move_new_since_to_new_table_again.rb
+++ b/db/migrate/20210218022739_move_new_since_to_new_table_again.rb
@@ -47,19 +47,20 @@ class MoveNewSinceToNewTableAgain < ActiveRecord::Migration[6.0]
ON CONFLICT DO NOTHING
SQL
- DB.exec(sql,
- now: DateTime.now,
- last_visit: User::NewTopicDuration::LAST_VISIT,
- always: User::NewTopicDuration::ALWAYS,
- default_duration: SiteSetting.default_other_new_topic_duration_minutes,
- min_date: Time.at(SiteSetting.min_new_topics_time).to_datetime,
- private_message: Archetype.private_message,
- min_id: min_id,
- max_id: max_id,
- max_new_topics: SiteSetting.max_new_topics)
+ DB.exec(
+ sql,
+ now: DateTime.now,
+ last_visit: User::NewTopicDuration::LAST_VISIT,
+ always: User::NewTopicDuration::ALWAYS,
+ default_duration: SiteSetting.default_other_new_topic_duration_minutes,
+ min_date: Time.at(SiteSetting.min_new_topics_time).to_datetime,
+ private_message: Archetype.private_message,
+ min_id: min_id,
+ max_id: max_id,
+ max_new_topics: SiteSetting.max_new_topics,
+ )
offset += BATCH_SIZE
-
end
end
diff --git a/db/migrate/20210308195916_add_unique_index_to_invited_groups.rb b/db/migrate/20210308195916_add_unique_index_to_invited_groups.rb
index c3f8b607694..4804d59b646 100644
--- a/db/migrate/20210308195916_add_unique_index_to_invited_groups.rb
+++ b/db/migrate/20210308195916_add_unique_index_to_invited_groups.rb
@@ -10,6 +10,6 @@ class AddUniqueIndexToInvitedGroups < ActiveRecord::Migration[6.0]
AND a.group_id = b.group_id
SQL
- add_index :invited_groups, [:group_id, :invite_id], unique: true
+ add_index :invited_groups, %i[group_id invite_id], unique: true
end
end
diff --git a/db/migrate/20210311070755_add_image_upload_id_to_badges.rb b/db/migrate/20210311070755_add_image_upload_id_to_badges.rb
index c9d15ee030f..d1be9ee2a97 100644
--- a/db/migrate/20210311070755_add_image_upload_id_to_badges.rb
+++ b/db/migrate/20210311070755_add_image_upload_id_to_badges.rb
@@ -3,9 +3,7 @@
class AddImageUploadIdToBadges < ActiveRecord::Migration[6.0]
def change
add_column :badges, :image_upload_id, :integer
- reversible do |dir|
- dir.up do
- DB.exec <<~SQL
+ reversible { |dir| dir.up { DB.exec <<~SQL } }
UPDATE badges b1
SET image_upload_id = u.id
FROM (
@@ -19,7 +17,5 @@ class AddImageUploadIdToBadges < ActiveRecord::Migration[6.0]
WHERE
b1.id = b2.id
SQL
- end
- end
end
end
diff --git a/db/migrate/20210315173137_set_disable_mailing_list_mode.rb b/db/migrate/20210315173137_set_disable_mailing_list_mode.rb
index 83abd1d93d4..d0b35f5040d 100644
--- a/db/migrate/20210315173137_set_disable_mailing_list_mode.rb
+++ b/db/migrate/20210315173137_set_disable_mailing_list_mode.rb
@@ -3,13 +3,11 @@
class SetDisableMailingListMode < ActiveRecord::Migration[6.0]
def up
result = execute "SELECT COUNT(*) FROM user_options WHERE mailing_list_mode"
- if result.first['count'] > 0
- execute <<~SQL
+ execute <<~SQL if result.first["count"] > 0
INSERT INTO site_settings(name, data_type, value, created_at, updated_at)
VALUES('disable_mailing_list_mode', 5, 'f', NOW(), NOW())
ON CONFLICT (name) DO NOTHING
SQL
- end
end
def down
diff --git a/db/migrate/20210406060434_fix_topic_user_bookmarked_sync_issues_again.rb b/db/migrate/20210406060434_fix_topic_user_bookmarked_sync_issues_again.rb
index 41aedc55544..94c0895b720 100644
--- a/db/migrate/20210406060434_fix_topic_user_bookmarked_sync_issues_again.rb
+++ b/db/migrate/20210406060434_fix_topic_user_bookmarked_sync_issues_again.rb
@@ -4,20 +4,16 @@ class FixTopicUserBookmarkedSyncIssuesAgain < ActiveRecord::Migration[6.0]
disable_ddl_transaction!
def up
- DB.exec(
- <<~SQL
+ DB.exec(<<~SQL)
UPDATE topic_users SET bookmarked = true
FROM bookmarks AS b
WHERE NOT topic_users.bookmarked AND topic_users.topic_id = b.topic_id AND topic_users.user_id = b.user_id
SQL
- )
- DB.exec(
- <<~SQL
+ DB.exec(<<~SQL)
UPDATE topic_users SET bookmarked = false
WHERE topic_users.bookmarked AND (SELECT COUNT(*) FROM bookmarks WHERE topic_id = topic_users.topic_id AND user_id = topic_users.user_id) = 0
SQL
- )
end
def down
diff --git a/db/migrate/20210414013318_add_category_setting_allow_unlimited_owner_edits_op.rb b/db/migrate/20210414013318_add_category_setting_allow_unlimited_owner_edits_op.rb
index 85fd8238138..13c74377d75 100644
--- a/db/migrate/20210414013318_add_category_setting_allow_unlimited_owner_edits_op.rb
+++ b/db/migrate/20210414013318_add_category_setting_allow_unlimited_owner_edits_op.rb
@@ -2,6 +2,10 @@
class AddCategorySettingAllowUnlimitedOwnerEditsOp < ActiveRecord::Migration[6.0]
def change
- add_column :categories, :allow_unlimited_owner_edits_on_first_post, :boolean, default: false, null: false
+ add_column :categories,
+ :allow_unlimited_owner_edits_on_first_post,
+ :boolean,
+ default: false,
+ null: false
end
end
diff --git a/db/migrate/20210527114834_set_tagging_enabled.rb b/db/migrate/20210527114834_set_tagging_enabled.rb
index 73e9fa74473..8e2dd92db46 100644
--- a/db/migrate/20210527114834_set_tagging_enabled.rb
+++ b/db/migrate/20210527114834_set_tagging_enabled.rb
@@ -10,13 +10,11 @@ class SetTaggingEnabled < ActiveRecord::Migration[6.1]
SQL
# keep tagging disabled for existing sites
- if result.first['created_at'].to_datetime < 1.hour.ago
- execute <<~SQL
+ execute <<~SQL if result.first["created_at"].to_datetime < 1.hour.ago
INSERT INTO site_settings(name, data_type, value, created_at, updated_at)
VALUES('tagging_enabled', 5, 'f', NOW(), NOW())
ON CONFLICT (name) DO NOTHING
SQL
- end
end
def down
diff --git a/db/migrate/20210527131318_create_directory_columns.rb b/db/migrate/20210527131318_create_directory_columns.rb
index 81fa5421d10..ec1a31d96ee 100644
--- a/db/migrate/20210527131318_create_directory_columns.rb
+++ b/db/migrate/20210527131318_create_directory_columns.rb
@@ -9,10 +9,10 @@ class CreateDirectoryColumns < ActiveRecord::Migration[6.1]
t.boolean :automatic, null: false
t.boolean :enabled, null: false
t.integer :position, null: false
- t.datetime :created_at, default: -> { 'CURRENT_TIMESTAMP' }
+ t.datetime :created_at, default: -> { "CURRENT_TIMESTAMP" }
end
- add_index :directory_columns, [:enabled, :position, :user_field_id], name: "directory_column_index"
+ add_index :directory_columns, %i[enabled position user_field_id], name: "directory_column_index"
create_automatic_columns
end
@@ -22,8 +22,7 @@ class CreateDirectoryColumns < ActiveRecord::Migration[6.1]
end
def create_automatic_columns
- DB.exec(
- <<~SQL
+ DB.exec(<<~SQL)
INSERT INTO directory_columns (
name, automatic, enabled, automatic_position, position, icon
)
@@ -36,6 +35,5 @@ class CreateDirectoryColumns < ActiveRecord::Migration[6.1]
( 'posts_read', true, true, 6, 6, NULL ),
( 'days_visited', true, true, 7, 7, NULL );
SQL
- )
end
end
diff --git a/db/migrate/20210528003603_fix_badge_image_avatar_upload_security_and_acls.rb b/db/migrate/20210528003603_fix_badge_image_avatar_upload_security_and_acls.rb
index e41c2f6d3df..8bd5e950914 100644
--- a/db/migrate/20210528003603_fix_badge_image_avatar_upload_security_and_acls.rb
+++ b/db/migrate/20210528003603_fix_badge_image_avatar_upload_security_and_acls.rb
@@ -4,13 +4,12 @@ class FixBadgeImageAvatarUploadSecurityAndAcls < ActiveRecord::Migration[6.1]
disable_ddl_transaction!
def up
- upload_ids = DB.query_single(<<~SQL
+ upload_ids = DB.query_single(<<~SQL)
SELECT image_upload_id
FROM badges
INNER JOIN uploads ON uploads.id = badges.image_upload_id
WHERE image_upload_id IS NOT NULL AND uploads.secure
SQL
- )
if upload_ids.any?
reason = "badge_image fixup migration"
diff --git a/db/migrate/20210601002145_rename_trust_level_translations.rb b/db/migrate/20210601002145_rename_trust_level_translations.rb
index b5cb17fd744..a974455d4d3 100644
--- a/db/migrate/20210601002145_rename_trust_level_translations.rb
+++ b/db/migrate/20210601002145_rename_trust_level_translations.rb
@@ -4,22 +4,18 @@ class RenameTrustLevelTranslations < ActiveRecord::Migration[6.1]
KEYS = %w[newuser basic member regular leader]
def up
- KEYS.each do |key|
- execute <<~SQL
+ KEYS.each { |key| execute <<~SQL }
UPDATE translation_overrides
SET translation_key = 'js.trust_levels.names.#{key}'
WHERE translation_key = 'trust_levels.#{key}.title'
SQL
- end
end
def down
- KEYS.each do |key|
- execute <<~SQL
+ KEYS.each { |key| execute <<~SQL }
UPDATE translation_overrides
SET translation_key = 'trust_levels.#{key}.title'
WHERE translation_key = 'js.trust_levels.names.#{key}'
SQL
- end
end
end
diff --git a/db/migrate/20210618135229_reintroduce_type_to_directory_columns.rb b/db/migrate/20210618135229_reintroduce_type_to_directory_columns.rb
index bb149e7eebb..d7f36dbc8b7 100644
--- a/db/migrate/20210618135229_reintroduce_type_to_directory_columns.rb
+++ b/db/migrate/20210618135229_reintroduce_type_to_directory_columns.rb
@@ -8,12 +8,10 @@ class ReintroduceTypeToDirectoryColumns < ActiveRecord::Migration[6.1]
add_column :directory_columns, :type, :integer, default: 0, null: false
end
- DB.exec(
- <<~SQL
+ DB.exec(<<~SQL)
UPDATE directory_columns
SET type = CASE WHEN automatic THEN 0 ELSE 1 END;
SQL
- )
end
def down
diff --git a/db/migrate/20210621002201_add_columns_to_email_log_to_match_incoming_for_smtp_imap.rb b/db/migrate/20210621002201_add_columns_to_email_log_to_match_incoming_for_smtp_imap.rb
index b9fea5f543e..0b1d6998244 100644
--- a/db/migrate/20210621002201_add_columns_to_email_log_to_match_incoming_for_smtp_imap.rb
+++ b/db/migrate/20210621002201_add_columns_to_email_log_to_match_incoming_for_smtp_imap.rb
@@ -7,7 +7,7 @@ class AddColumnsToEmailLogToMatchIncomingForSmtpImap < ActiveRecord::Migration[6
add_column :email_logs, :raw, :text, null: true
add_column :email_logs, :topic_id, :integer, null: true
- add_index :email_logs, :topic_id, where: 'topic_id IS NOT NULL'
+ add_index :email_logs, :topic_id, where: "topic_id IS NOT NULL"
end
def down
diff --git a/db/migrate/20210621103509_add_bannered_until.rb b/db/migrate/20210621103509_add_bannered_until.rb
index 6a48cf416e1..96baba8305a 100644
--- a/db/migrate/20210621103509_add_bannered_until.rb
+++ b/db/migrate/20210621103509_add_bannered_until.rb
@@ -4,6 +4,6 @@ class AddBanneredUntil < ActiveRecord::Migration[6.1]
def change
add_column :topics, :bannered_until, :datetime, null: true
- add_index :topics, :bannered_until, where: 'bannered_until IS NOT NULL'
+ add_index :topics, :bannered_until, where: "bannered_until IS NOT NULL"
end
end
diff --git a/db/migrate/20210621190335_migrate_pending_users_reminder_delay_setting.rb b/db/migrate/20210621190335_migrate_pending_users_reminder_delay_setting.rb
index a1cd158c9d5..dd633617eba 100644
--- a/db/migrate/20210621190335_migrate_pending_users_reminder_delay_setting.rb
+++ b/db/migrate/20210621190335_migrate_pending_users_reminder_delay_setting.rb
@@ -2,7 +2,10 @@
class MigratePendingUsersReminderDelaySetting < ActiveRecord::Migration[6.1]
def up
- setting_value = DB.query_single("SELECT value FROM site_settings WHERE name = 'pending_users_reminder_delay'").first
+ setting_value =
+ DB.query_single(
+ "SELECT value FROM site_settings WHERE name = 'pending_users_reminder_delay'",
+ ).first
if setting_value.present?
new_value = setting_value.to_i
diff --git a/db/migrate/20210624023831_remove_highest_seen_post_number_from_topic_users.rb b/db/migrate/20210624023831_remove_highest_seen_post_number_from_topic_users.rb
index dbf2cdc3e25..da77919333c 100644
--- a/db/migrate/20210624023831_remove_highest_seen_post_number_from_topic_users.rb
+++ b/db/migrate/20210624023831_remove_highest_seen_post_number_from_topic_users.rb
@@ -1,16 +1,12 @@
# frozen_string_literal: true
-require 'migration/column_dropper'
+require "migration/column_dropper"
class RemoveHighestSeenPostNumberFromTopicUsers < ActiveRecord::Migration[6.1]
- DROPPED_COLUMNS = {
- topic_users: %i{highest_seen_post_number}
- }
+ DROPPED_COLUMNS = { topic_users: %i[highest_seen_post_number] }
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
diff --git a/db/migrate/20210628035905_drop_duration_column_from_topic_timers.rb b/db/migrate/20210628035905_drop_duration_column_from_topic_timers.rb
index f8e8ee2c73e..dc231c2ca1e 100644
--- a/db/migrate/20210628035905_drop_duration_column_from_topic_timers.rb
+++ b/db/migrate/20210628035905_drop_duration_column_from_topic_timers.rb
@@ -1,14 +1,10 @@
# frozen_string_literal: true
class DropDurationColumnFromTopicTimers < ActiveRecord::Migration[6.1]
- DROPPED_COLUMNS ||= {
- topic_timers: %i{duration}
- }
+ DROPPED_COLUMNS ||= { topic_timers: %i[duration] }
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
diff --git a/db/migrate/20210706091905_drop_disable_jump_reply_column_from_user_options.rb b/db/migrate/20210706091905_drop_disable_jump_reply_column_from_user_options.rb
index e9efd44ab22..59b105435b5 100644
--- a/db/migrate/20210706091905_drop_disable_jump_reply_column_from_user_options.rb
+++ b/db/migrate/20210706091905_drop_disable_jump_reply_column_from_user_options.rb
@@ -1,14 +1,10 @@
# frozen_string_literal: true
class DropDisableJumpReplyColumnFromUserOptions < ActiveRecord::Migration[6.1]
- DROPPED_COLUMNS ||= {
- user_options: %i{disable_jump_reply}
- }
+ DROPPED_COLUMNS ||= { user_options: %i[disable_jump_reply] }
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
diff --git a/db/migrate/20210709053030_drop_uploads_verified.rb b/db/migrate/20210709053030_drop_uploads_verified.rb
index bbf6a7dde55..5f999b35197 100644
--- a/db/migrate/20210709053030_drop_uploads_verified.rb
+++ b/db/migrate/20210709053030_drop_uploads_verified.rb
@@ -1,14 +1,10 @@
# frozen_string_literal: true
class DropUploadsVerified < ActiveRecord::Migration[6.1]
- DROPPED_COLUMNS ||= {
- uploads: %i{verified}
- }
+ DROPPED_COLUMNS ||= { uploads: %i[verified] }
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
diff --git a/db/migrate/20210824203421_remove_post_timings_summary_index.rb b/db/migrate/20210824203421_remove_post_timings_summary_index.rb
index 856a89e7d0c..cd9f4c625cf 100644
--- a/db/migrate/20210824203421_remove_post_timings_summary_index.rb
+++ b/db/migrate/20210824203421_remove_post_timings_summary_index.rb
@@ -2,6 +2,9 @@
class RemovePostTimingsSummaryIndex < ActiveRecord::Migration[6.1]
def change
- remove_index :post_timings, column: [:topic_id, :post_number], name: :post_timings_summary, if_exists: true
+ remove_index :post_timings,
+ column: %i[topic_id post_number],
+ name: :post_timings_summary,
+ if_exists: true
end
end
diff --git a/db/migrate/20210913032326_add_for_topic_to_bookmarks.rb b/db/migrate/20210913032326_add_for_topic_to_bookmarks.rb
index 84524f570e0..796d5fd4d75 100644
--- a/db/migrate/20210913032326_add_for_topic_to_bookmarks.rb
+++ b/db/migrate/20210913032326_add_for_topic_to_bookmarks.rb
@@ -3,9 +3,7 @@
class AddForTopicToBookmarks < ActiveRecord::Migration[6.1]
def change
add_column :bookmarks, :for_topic, :boolean, default: false, null: false
- add_index :bookmarks, [:user_id, :post_id, :for_topic], unique: true
- if index_exists?(:bookmarks, [:user_id, :post_id])
- remove_index :bookmarks, [:user_id, :post_id]
- end
+ add_index :bookmarks, %i[user_id post_id for_topic], unique: true
+ remove_index :bookmarks, %i[user_id post_id] if index_exists?(:bookmarks, %i[user_id post_id])
end
end
diff --git a/db/migrate/20210915222124_drop_reminder_type_index_for_bookmarks.rb b/db/migrate/20210915222124_drop_reminder_type_index_for_bookmarks.rb
index 06e9fb010ea..f10471face7 100644
--- a/db/migrate/20210915222124_drop_reminder_type_index_for_bookmarks.rb
+++ b/db/migrate/20210915222124_drop_reminder_type_index_for_bookmarks.rb
@@ -2,14 +2,10 @@
class DropReminderTypeIndexForBookmarks < ActiveRecord::Migration[6.1]
def up
- if index_exists?(:bookmarks, [:reminder_type])
- remove_index :bookmarks, [:reminder_type]
- end
+ remove_index :bookmarks, [:reminder_type] if index_exists?(:bookmarks, [:reminder_type])
end
def down
- if !index_exists?(:bookmarks, [:reminder_type])
- add_index :bookmarks, :reminder_type
- end
+ add_index :bookmarks, :reminder_type if !index_exists?(:bookmarks, [:reminder_type])
end
end
diff --git a/db/migrate/20210920044353_add_default_calendar_to_user_options.rb b/db/migrate/20210920044353_add_default_calendar_to_user_options.rb
index 0bbc5a3c73b..169e792083a 100644
--- a/db/migrate/20210920044353_add_default_calendar_to_user_options.rb
+++ b/db/migrate/20210920044353_add_default_calendar_to_user_options.rb
@@ -3,6 +3,6 @@
class AddDefaultCalendarToUserOptions < ActiveRecord::Migration[6.1]
def change
add_column :user_options, :default_calendar, :integer, default: 0, null: false
- add_index :user_options, [:user_id, :default_calendar]
+ add_index :user_options, %i[user_id default_calendar]
end
end
diff --git a/db/migrate/20210929215543_add_token_hash_to_email_token.rb b/db/migrate/20210929215543_add_token_hash_to_email_token.rb
index b691b3cedf7..ca2ad4dd218 100644
--- a/db/migrate/20210929215543_add_token_hash_to_email_token.rb
+++ b/db/migrate/20210929215543_add_token_hash_to_email_token.rb
@@ -5,9 +5,10 @@ class AddTokenHashToEmailToken < ActiveRecord::Migration[6.1]
add_column :email_tokens, :token_hash, :string
loop do
- rows = DB
- .query("SELECT id, token FROM email_tokens WHERE token_hash IS NULL LIMIT 500")
- .map { |row| { id: row.id, token_hash: Digest::SHA256.hexdigest(row.token) } }
+ rows =
+ DB
+ .query("SELECT id, token FROM email_tokens WHERE token_hash IS NULL LIMIT 500")
+ .map { |row| { id: row.id, token_hash: Digest::SHA256.hexdigest(row.token) } }
break if rows.size == 0
diff --git a/db/migrate/20211106085344_create_associated_groups.rb b/db/migrate/20211106085344_create_associated_groups.rb
index 72c441fe5fa..ffdad1f29f3 100644
--- a/db/migrate/20211106085344_create_associated_groups.rb
+++ b/db/migrate/20211106085344_create_associated_groups.rb
@@ -10,6 +10,9 @@ class CreateAssociatedGroups < ActiveRecord::Migration[6.1]
t.timestamps
end
- add_index :associated_groups, %i[provider_name provider_id], unique: true, name: 'associated_groups_provider_id'
+ add_index :associated_groups,
+ %i[provider_name provider_id],
+ unique: true,
+ name: "associated_groups_provider_id"
end
end
diff --git a/db/migrate/20211106085527_create_user_associated_groups.rb b/db/migrate/20211106085527_create_user_associated_groups.rb
index 73464b66f47..25ae89ec8df 100644
--- a/db/migrate/20211106085527_create_user_associated_groups.rb
+++ b/db/migrate/20211106085527_create_user_associated_groups.rb
@@ -8,6 +8,9 @@ class CreateUserAssociatedGroups < ActiveRecord::Migration[6.1]
t.timestamps
end
- add_index :user_associated_groups, %i[user_id associated_group_id], unique: true, name: 'index_user_associated_groups'
+ add_index :user_associated_groups,
+ %i[user_id associated_group_id],
+ unique: true,
+ name: "index_user_associated_groups"
end
end
diff --git a/db/migrate/20211106085605_create_group_associated_groups.rb b/db/migrate/20211106085605_create_group_associated_groups.rb
index 281adb11b17..384231495d7 100644
--- a/db/migrate/20211106085605_create_group_associated_groups.rb
+++ b/db/migrate/20211106085605_create_group_associated_groups.rb
@@ -8,6 +8,9 @@ class CreateGroupAssociatedGroups < ActiveRecord::Migration[6.1]
t.timestamps
end
- add_index :group_associated_groups, %i[group_id associated_group_id], unique: true, name: 'index_group_associated_groups'
+ add_index :group_associated_groups,
+ %i[group_id associated_group_id],
+ unique: true,
+ name: "index_group_associated_groups"
end
end
diff --git a/db/migrate/20211123144714_add_recent_searches.rb b/db/migrate/20211123144714_add_recent_searches.rb
index 0e586f6afb2..43ffe229e24 100644
--- a/db/migrate/20211123144714_add_recent_searches.rb
+++ b/db/migrate/20211123144714_add_recent_searches.rb
@@ -4,6 +4,6 @@ class AddRecentSearches < ActiveRecord::Migration[6.1]
def change
add_column :user_options, :oldest_search_log_date, :datetime
- add_index :search_logs, [:user_id, :created_at], where: 'user_id IS NOT NULL'
+ add_index :search_logs, %i[user_id created_at], where: "user_id IS NOT NULL"
end
end
diff --git a/db/migrate/20211124161346_queue_internal_onebox_rebake.rb b/db/migrate/20211124161346_queue_internal_onebox_rebake.rb
index 85af7f1ceea..a58d527182b 100644
--- a/db/migrate/20211124161346_queue_internal_onebox_rebake.rb
+++ b/db/migrate/20211124161346_queue_internal_onebox_rebake.rb
@@ -4,12 +4,10 @@ class QueueInternalOneboxRebake < ActiveRecord::Migration[6.1]
def up
# Prior to this fix, internal oneboxes were bypassing the CDN for avatar URLs.
# If a site has a CDN, queue up a rebake in the background
- if GlobalSetting.cdn_url
- execute <<~SQL
+ execute <<~SQL if GlobalSetting.cdn_url
UPDATE posts SET baked_version = 0
WHERE cooked LIKE '%src="/user_avatar/%'
SQL
- end
end
def down
diff --git a/db/migrate/20211201221028_migrate_email_to_normalized_email.rb b/db/migrate/20211201221028_migrate_email_to_normalized_email.rb
index 2839c8f2fd0..d84d7cf4d43 100644
--- a/db/migrate/20211201221028_migrate_email_to_normalized_email.rb
+++ b/db/migrate/20211201221028_migrate_email_to_normalized_email.rb
@@ -1,12 +1,10 @@
# frozen_string_literal: true
class MigrateEmailToNormalizedEmail < ActiveRecord::Migration[6.1]
-
# minimize locking on user_email table
disable_ddl_transaction!
def up
-
min, max = DB.query_single "SELECT MIN(id), MAX(id) FROM user_emails"
# scaling is needed to compensate for "holes" where records were deleted
# and pathological cases where for some reason id 100_000_000 and 0 exist
@@ -29,7 +27,6 @@ class MigrateEmailToNormalizedEmail < ActiveRecord::Migration[6.1]
low_id = min
bounds.each do |high_id|
-
# using execute cause MiniSQL is not logging at the moment
# to_i is not needed, but specified so it is explicit there is no SQL injection
execute <<~SQL
@@ -41,7 +38,6 @@ class MigrateEmailToNormalizedEmail < ActiveRecord::Migration[6.1]
low_id = high_id
end
-
end
def down
diff --git a/db/migrate/20211206160212_drop_token_from_email_tokens.rb b/db/migrate/20211206160212_drop_token_from_email_tokens.rb
index 2e65cdb4a50..f42cd01ddcd 100644
--- a/db/migrate/20211206160212_drop_token_from_email_tokens.rb
+++ b/db/migrate/20211206160212_drop_token_from_email_tokens.rb
@@ -1,14 +1,10 @@
# frozen_string_literal: true
class DropTokenFromEmailTokens < ActiveRecord::Migration[6.1]
- DROPPED_COLUMNS ||= {
- email_tokens: %i{token}
- }
+ DROPPED_COLUMNS ||= { email_tokens: %i[token] }
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
diff --git a/db/migrate/20211213060445_email_tokens_token_to_nullable.rb b/db/migrate/20211213060445_email_tokens_token_to_nullable.rb
index 1207ae1825e..16f542f01ca 100644
--- a/db/migrate/20211213060445_email_tokens_token_to_nullable.rb
+++ b/db/migrate/20211213060445_email_tokens_token_to_nullable.rb
@@ -9,16 +9,14 @@ class EmailTokensTokenToNullable < ActiveRecord::Migration[6.1]
# drifted on main
begin
Migration::SafeMigrate.disable!
- if DB.query_single(<<~SQL).length > 0
+ execute <<~SQL if DB.query_single(<<~SQL).length > 0
+ ALTER TABLE email_tokens ALTER COLUMN token DROP NOT NULL
+ SQL
SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_schema='public'
AND table_name = 'email_tokens'
AND column_name = 'token'
SQL
- execute <<~SQL
- ALTER TABLE email_tokens ALTER COLUMN token DROP NOT NULL
- SQL
- end
ensure
Migration::SafeMigrate.enable!
end
diff --git a/db/migrate/20211224010204_drop_old_bookmark_columns.rb b/db/migrate/20211224010204_drop_old_bookmark_columns.rb
index 6dc3e8354c3..48793b0f2a0 100644
--- a/db/migrate/20211224010204_drop_old_bookmark_columns.rb
+++ b/db/migrate/20211224010204_drop_old_bookmark_columns.rb
@@ -1,19 +1,12 @@
# frozen_string_literal: true
-require 'migration/column_dropper'
+require "migration/column_dropper"
class DropOldBookmarkColumns < ActiveRecord::Migration[6.1]
- DROPPED_COLUMNS ||= {
- bookmarks: %i{
- topic_id
- reminder_type
- }
- }
+ DROPPED_COLUMNS ||= { bookmarks: %i[topic_id reminder_type] }
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
diff --git a/db/migrate/20211224111749_not_null_notification_level_in_category_users.rb b/db/migrate/20211224111749_not_null_notification_level_in_category_users.rb
index 8638bb447b1..be401dd3d5d 100644
--- a/db/migrate/20211224111749_not_null_notification_level_in_category_users.rb
+++ b/db/migrate/20211224111749_not_null_notification_level_in_category_users.rb
@@ -2,9 +2,7 @@
class NotNullNotificationLevelInCategoryUsers < ActiveRecord::Migration[6.1]
def change
- up_only do
- execute("DELETE FROM category_users WHERE notification_level IS NULL")
- end
+ up_only { execute("DELETE FROM category_users WHERE notification_level IS NULL") }
change_column_null :category_users, :notification_level, false
end
end
diff --git a/db/migrate/20220130192155_set_use_email_for_username_and_name_suggestions_on_existing_sites.rb b/db/migrate/20220130192155_set_use_email_for_username_and_name_suggestions_on_existing_sites.rb
index 22b19c60dbb..29f9a078124 100644
--- a/db/migrate/20220130192155_set_use_email_for_username_and_name_suggestions_on_existing_sites.rb
+++ b/db/migrate/20220130192155_set_use_email_for_username_and_name_suggestions_on_existing_sites.rb
@@ -10,13 +10,11 @@ class SetUseEmailForUsernameAndNameSuggestionsOnExistingSites < ActiveRecord::Mi
SQL
# make setting enabled for existing sites
- if result.first['created_at'].to_datetime < 1.hour.ago
- execute <<~SQL
+ execute <<~SQL if result.first["created_at"].to_datetime < 1.hour.ago
INSERT INTO site_settings(name, data_type, value, created_at, updated_at)
VALUES('use_email_for_username_and_name_suggestions', 5, 't', NOW(), NOW())
ON CONFLICT (name) DO NOTHING
SQL
- end
end
def down
diff --git a/db/migrate/20220202225716_add_external_id_to_topics.rb b/db/migrate/20220202225716_add_external_id_to_topics.rb
index 6ee7c3edb52..2e04ceddc7c 100644
--- a/db/migrate/20220202225716_add_external_id_to_topics.rb
+++ b/db/migrate/20220202225716_add_external_id_to_topics.rb
@@ -3,6 +3,6 @@
class AddExternalIdToTopics < ActiveRecord::Migration[6.1]
def change
add_column :topics, :external_id, :string, null: true
- add_index :topics, :external_id, unique: true, where: 'external_id IS NOT NULL'
+ add_index :topics, :external_id, unique: true, where: "external_id IS NOT NULL"
end
end
diff --git a/db/migrate/20220302163246_update_avatar_service_domain.rb b/db/migrate/20220302163246_update_avatar_service_domain.rb
index b602c501a55..dd9624250f8 100644
--- a/db/migrate/20220302163246_update_avatar_service_domain.rb
+++ b/db/migrate/20220302163246_update_avatar_service_domain.rb
@@ -2,7 +2,10 @@
class UpdateAvatarServiceDomain < ActiveRecord::Migration[6.1]
def up
- existing_value = DB.query_single("SELECT value FROM site_settings WHERE name = 'external_system_avatars_url'")&.[](0)
+ existing_value =
+ DB.query_single(
+ "SELECT value FROM site_settings WHERE name = 'external_system_avatars_url'",
+ )&.[](0)
if existing_value&.include?("avatars.discourse.org")
new_value = DB.query_single(<<~SQL)&.[](0)
diff --git a/db/migrate/20220304162250_enable_unaccent_extension.rb b/db/migrate/20220304162250_enable_unaccent_extension.rb
index d6f6e7f770e..5991caac1ce 100644
--- a/db/migrate/20220304162250_enable_unaccent_extension.rb
+++ b/db/migrate/20220304162250_enable_unaccent_extension.rb
@@ -2,6 +2,6 @@
class EnableUnaccentExtension < ActiveRecord::Migration[6.1]
def change
- enable_extension 'unaccent'
+ enable_extension "unaccent"
end
end
diff --git a/db/migrate/20220308201942_create_upload_references.rb b/db/migrate/20220308201942_create_upload_references.rb
index 84891f80a52..3f928526b38 100644
--- a/db/migrate/20220308201942_create_upload_references.rb
+++ b/db/migrate/20220308201942_create_upload_references.rb
@@ -8,6 +8,9 @@ class CreateUploadReferences < ActiveRecord::Migration[6.1]
t.timestamps
end
- add_index :upload_references, [:upload_id, :target_type, :target_id], unique: true, name: 'index_upload_references_on_upload_and_target'
+ add_index :upload_references,
+ %i[upload_id target_type target_id],
+ unique: true,
+ name: "index_upload_references_on_upload_and_target"
end
end
diff --git a/db/migrate/20220322024216_add_bookmark_polymorphic_columns.rb b/db/migrate/20220322024216_add_bookmark_polymorphic_columns.rb
index 922d611d5f3..fc7b34d11ed 100644
--- a/db/migrate/20220322024216_add_bookmark_polymorphic_columns.rb
+++ b/db/migrate/20220322024216_add_bookmark_polymorphic_columns.rb
@@ -10,8 +10,11 @@ class AddBookmarkPolymorphicColumns < ActiveRecord::Migration[6.1]
add_column :bookmarks, :bookmarkable_type, :string
end
- if !index_exists?(:bookmarks, [:user_id, :bookmarkable_type, :bookmarkable_id])
- add_index :bookmarks, [:user_id, :bookmarkable_type, :bookmarkable_id], name: "idx_bookmarks_user_polymorphic_unique", unique: true
+ if !index_exists?(:bookmarks, %i[user_id bookmarkable_type bookmarkable_id])
+ add_index :bookmarks,
+ %i[user_id bookmarkable_type bookmarkable_id],
+ name: "idx_bookmarks_user_polymorphic_unique",
+ unique: true
end
end
end
diff --git a/db/migrate/20220401130745_create_category_required_tag_groups.rb b/db/migrate/20220401130745_create_category_required_tag_groups.rb
index dd054a9e11b..b6e3193922f 100644
--- a/db/migrate/20220401130745_create_category_required_tag_groups.rb
+++ b/db/migrate/20220401130745_create_category_required_tag_groups.rb
@@ -10,7 +10,10 @@ class CreateCategoryRequiredTagGroups < ActiveRecord::Migration[6.1]
t.timestamps
end
- add_index :category_required_tag_groups, [:category_id, :tag_group_id], name: "idx_category_required_tag_groups", unique: true
+ add_index :category_required_tag_groups,
+ %i[category_id tag_group_id],
+ name: "idx_category_required_tag_groups",
+ unique: true
execute <<~SQL
INSERT INTO category_required_tag_groups
diff --git a/db/migrate/20220428094026_create_post_hotlinked_media.rb b/db/migrate/20220428094026_create_post_hotlinked_media.rb
index ff31138ccd6..27354aa4952 100644
--- a/db/migrate/20220428094026_create_post_hotlinked_media.rb
+++ b/db/migrate/20220428094026_create_post_hotlinked_media.rb
@@ -3,16 +3,12 @@
class CreatePostHotlinkedMedia < ActiveRecord::Migration[6.1]
def change
reversible do |dir|
- dir.up do
- execute <<~SQL
+ dir.up { execute <<~SQL }
CREATE TYPE hotlinked_media_status AS ENUM('downloaded', 'too_large', 'download_failed', 'upload_create_failed')
SQL
- end
- dir.down do
- execute <<~SQL
+ dir.down { execute <<~SQL }
DROP TYPE hotlinked_media_status
SQL
- end
end
create_table :post_hotlinked_media do |t|
diff --git a/db/migrate/20220506221447_set_pm_tags_allowed_for_groups_default.rb b/db/migrate/20220506221447_set_pm_tags_allowed_for_groups_default.rb
index e7a36eec4d5..c28b832e11d 100644
--- a/db/migrate/20220506221447_set_pm_tags_allowed_for_groups_default.rb
+++ b/db/migrate/20220506221447_set_pm_tags_allowed_for_groups_default.rb
@@ -2,10 +2,10 @@
class SetPmTagsAllowedForGroupsDefault < ActiveRecord::Migration[7.0]
def up
-
# if the old SiteSetting of `allow_staff_to_tag_pms` was set to true, update the new SiteSetting of
# `pm_tags_allowed_for_groups` default to include the staff group
- allow_staff_to_tag_pms = DB.query_single("SELECT value FROM site_settings WHERE name = 'allow_staff_to_tag_pms'").first
+ allow_staff_to_tag_pms =
+ DB.query_single("SELECT value FROM site_settings WHERE name = 'allow_staff_to_tag_pms'").first
# Dynamically sets the default value
if allow_staff_to_tag_pms == "t"
diff --git a/db/migrate/20220628031850_create_sidebar_section_links.rb b/db/migrate/20220628031850_create_sidebar_section_links.rb
index 3bd1bad37fa..ab34ecb5f34 100644
--- a/db/migrate/20220628031850_create_sidebar_section_links.rb
+++ b/db/migrate/20220628031850_create_sidebar_section_links.rb
@@ -5,11 +5,14 @@ class CreateSidebarSectionLinks < ActiveRecord::Migration[7.0]
create_table :sidebar_section_links do |t|
t.integer :user_id, null: false
t.integer :linkable_id, null: false
- t.string :linkable_type, null: false
+ t.string :linkable_type, null: false
t.timestamps
end
- add_index :sidebar_section_links, [:user_id, :linkable_type, :linkable_id], unique: true, name: 'idx_unique_sidebar_section_links'
+ add_index :sidebar_section_links,
+ %i[user_id linkable_type linkable_id],
+ unique: true,
+ name: "idx_unique_sidebar_section_links"
end
end
diff --git a/db/migrate/20220726164831_fix_delete_rejected_email_after_days_site_setting.rb b/db/migrate/20220726164831_fix_delete_rejected_email_after_days_site_setting.rb
index 89ce57c1d8c..70b6d9641df 100644
--- a/db/migrate/20220726164831_fix_delete_rejected_email_after_days_site_setting.rb
+++ b/db/migrate/20220726164831_fix_delete_rejected_email_after_days_site_setting.rb
@@ -1,8 +1,14 @@
# frozen_string_literal: true
class FixDeleteRejectedEmailAfterDaysSiteSetting < ActiveRecord::Migration[6.1]
def up
- delete_rejected_email_after_days = DB.query_single("SELECT value FROM site_settings WHERE name = 'delete_rejected_email_after_days'").first
- delete_email_logs_after_days = DB.query_single("SELECT value FROM site_settings WHERE name = 'delete_email_logs_after_days'").first
+ delete_rejected_email_after_days =
+ DB.query_single(
+ "SELECT value FROM site_settings WHERE name = 'delete_rejected_email_after_days'",
+ ).first
+ delete_email_logs_after_days =
+ DB.query_single(
+ "SELECT value FROM site_settings WHERE name = 'delete_email_logs_after_days'",
+ ).first
# These settings via the sql query return nil if they are using their default values
unless delete_email_logs_after_days
@@ -10,14 +16,14 @@ class FixDeleteRejectedEmailAfterDaysSiteSetting < ActiveRecord::Migration[6.1]
end
# Only update if the setting is not using the default and it is lower than 'delete_email_logs_after_days'
- if delete_rejected_email_after_days != nil && delete_rejected_email_after_days.to_i < delete_email_logs_after_days.to_i
+ if delete_rejected_email_after_days != nil &&
+ delete_rejected_email_after_days.to_i < delete_email_logs_after_days.to_i
execute <<~SQL
UPDATE site_settings
SET value = #{delete_email_logs_after_days.to_i}
WHERE name = 'delete_rejected_email_after_days'
SQL
end
-
end
def down
diff --git a/db/migrate/20220727085001_create_index_on_reviewables_score_desc_created_at_desc.rb b/db/migrate/20220727085001_create_index_on_reviewables_score_desc_created_at_desc.rb
index b2cc0ec199f..cdf780428f9 100644
--- a/db/migrate/20220727085001_create_index_on_reviewables_score_desc_created_at_desc.rb
+++ b/db/migrate/20220727085001_create_index_on_reviewables_score_desc_created_at_desc.rb
@@ -4,9 +4,12 @@ class CreateIndexOnReviewablesScoreDescCreatedAtDesc < ActiveRecord::Migration[7
def change
add_index(
:reviewables,
- [:score, :created_at],
- order: { score: :desc, created_at: :desc },
- name: 'idx_reviewables_score_desc_created_at_desc'
+ %i[score created_at],
+ order: {
+ score: :desc,
+ created_at: :desc,
+ },
+ name: "idx_reviewables_score_desc_created_at_desc",
)
end
end
diff --git a/db/migrate/20220825054405_fill_personal_message_enabled_groups_based_on_deprecated_settings.rb b/db/migrate/20220825054405_fill_personal_message_enabled_groups_based_on_deprecated_settings.rb
index cc10befd0f7..28241e035d5 100644
--- a/db/migrate/20220825054405_fill_personal_message_enabled_groups_based_on_deprecated_settings.rb
+++ b/db/migrate/20220825054405_fill_personal_message_enabled_groups_based_on_deprecated_settings.rb
@@ -2,11 +2,19 @@
class FillPersonalMessageEnabledGroupsBasedOnDeprecatedSettings < ActiveRecord::Migration[7.0]
def up
- enable_personal_messages_raw = DB.query_single("SELECT value FROM site_settings WHERE name = 'enable_personal_messages'").first
- enable_personal_messages = enable_personal_messages_raw.blank? || enable_personal_messages_raw == 't'
+ enable_personal_messages_raw =
+ DB.query_single(
+ "SELECT value FROM site_settings WHERE name = 'enable_personal_messages'",
+ ).first
+ enable_personal_messages =
+ enable_personal_messages_raw.blank? || enable_personal_messages_raw == "t"
- min_trust_to_send_messages_raw = DB.query_single("SELECT value FROM site_settings WHERE name = 'min_trust_to_send_messages'").first
- min_trust_to_send_messages = (min_trust_to_send_messages_raw.blank? ? 1 : min_trust_to_send_messages_raw).to_i
+ min_trust_to_send_messages_raw =
+ DB.query_single(
+ "SELECT value FROM site_settings WHERE name = 'min_trust_to_send_messages'",
+ ).first
+ min_trust_to_send_messages =
+ (min_trust_to_send_messages_raw.blank? ? 1 : min_trust_to_send_messages_raw).to_i
# default to TL1, Group::AUTO_GROUPS[:trust_level_1] is 11
personal_message_enabled_groups = "11"
@@ -17,15 +25,13 @@ class FillPersonalMessageEnabledGroupsBasedOnDeprecatedSettings < ActiveRecord::
end
# only allow staff if the setting was previously disabled, Group::AUTO_GROUPS[:staff] is 3
- if !enable_personal_messages
- personal_message_enabled_groups = "3"
- end
+ personal_message_enabled_groups = "3" if !enable_personal_messages
# data_type 20 is group_list
DB.exec(
"INSERT INTO site_settings(name, value, data_type, created_at, updated_at)
VALUES('personal_message_enabled_groups', :setting, '20', NOW(), NOW())",
- setting: personal_message_enabled_groups
+ setting: personal_message_enabled_groups,
)
end
diff --git a/db/migrate/20220927065328_set_secure_uploads_settings_based_on_secure_media_equivalent.rb b/db/migrate/20220927065328_set_secure_uploads_settings_based_on_secure_media_equivalent.rb
index 037968a5345..1fa50a9219a 100644
--- a/db/migrate/20220927065328_set_secure_uploads_settings_based_on_secure_media_equivalent.rb
+++ b/db/migrate/20220927065328_set_secure_uploads_settings_based_on_secure_media_equivalent.rb
@@ -2,32 +2,36 @@
class SetSecureUploadsSettingsBasedOnSecureMediaEquivalent < ActiveRecord::Migration[7.0]
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"
INSERT INTO site_settings(name, data_type, value, created_at, updated_at)
VALUES ('secure_uploads', 5, 't', now(), now())
SQL
- end
- secure_media_allow_embed_images_in_emails = DB.query_single("SELECT value FROM site_settings WHERE name = 'secure_media_allow_embed_images_in_emails'")
+ secure_media_allow_embed_images_in_emails =
+ DB.query_single(
+ "SELECT value FROM site_settings WHERE name = 'secure_media_allow_embed_images_in_emails'",
+ )
- if secure_media_allow_embed_images_in_emails.present? && secure_media_allow_embed_images_in_emails[0] == "t"
+ if secure_media_allow_embed_images_in_emails.present? &&
+ secure_media_allow_embed_images_in_emails[0] == "t"
execute <<~SQL
INSERT INTO site_settings(name, data_type, value, created_at, updated_at)
VALUES ('secure_uploads_allow_embed_images_in_emails', 5, 't', now(), now())
SQL
end
- secure_media_max_email_embed_image_size_kb = DB.query_single("SELECT value FROM site_settings WHERE name = 'secure_media_max_email_embed_image_size_kb'")
+ secure_media_max_email_embed_image_size_kb =
+ DB.query_single(
+ "SELECT value FROM site_settings WHERE name = 'secure_media_max_email_embed_image_size_kb'",
+ )
- if secure_media_max_email_embed_image_size_kb.present?
- execute <<~SQL
+ execute <<~SQL if secure_media_max_email_embed_image_size_kb.present?
INSERT INTO site_settings(name, data_type, value, created_at, updated_at)
VALUES ('secure_uploads_max_email_embed_image_size_kb', 3, '#{secure_media_max_email_embed_image_size_kb[0]}', now(), now())
SQL
- end
end
def down
diff --git a/db/migrate/20220927171707_disable_allow_uncategorized_new_sites.rb b/db/migrate/20220927171707_disable_allow_uncategorized_new_sites.rb
index 979b8a6b563..82827c5537c 100644
--- a/db/migrate/20220927171707_disable_allow_uncategorized_new_sites.rb
+++ b/db/migrate/20220927171707_disable_allow_uncategorized_new_sites.rb
@@ -10,13 +10,11 @@ class DisableAllowUncategorizedNewSites < ActiveRecord::Migration[7.0]
SQL
# keep allow uncategorized for existing sites
- if result.first['created_at'].to_datetime < 1.hour.ago
- execute <<~SQL
+ execute <<~SQL if result.first["created_at"].to_datetime < 1.hour.ago
INSERT INTO site_settings(name, data_type, value, created_at, updated_at)
VALUES('allow_uncategorized_topics', 5, 't', NOW(), NOW())
ON CONFLICT (name) DO NOTHING
SQL
- end
end
def down
diff --git a/db/migrate/20221017223309_fix_general_category_id.rb b/db/migrate/20221017223309_fix_general_category_id.rb
index f51f8f0a496..f2243d89a2b 100644
--- a/db/migrate/20221017223309_fix_general_category_id.rb
+++ b/db/migrate/20221017223309_fix_general_category_id.rb
@@ -6,9 +6,11 @@
class FixGeneralCategoryId < ActiveRecord::Migration[7.0]
def up
- general_category_id = DB.query_single("SELECT value FROM site_settings WHERE name = 'general_category_id'")
+ general_category_id =
+ DB.query_single("SELECT value FROM site_settings WHERE name = 'general_category_id'")
return if general_category_id.blank? || general_category_id[0].to_i < 0
- matching_category_id = DB.query_single("SELECT id FROM categories WHERE id = #{general_category_id[0]}")
+ matching_category_id =
+ DB.query_single("SELECT id FROM categories WHERE id = #{general_category_id[0]}")
# If the general_category_id has been set to something other than the default and there isn't a matching
# category to go with it we should set it back to the default.
diff --git a/db/migrate/20221110175456_populate_default_composer_category.rb b/db/migrate/20221110175456_populate_default_composer_category.rb
index 812e9ba0ae9..22692d3ea11 100644
--- a/db/migrate/20221110175456_populate_default_composer_category.rb
+++ b/db/migrate/20221110175456_populate_default_composer_category.rb
@@ -5,14 +5,16 @@
class PopulateDefaultComposerCategory < ActiveRecord::Migration[7.0]
def up
- general_category_id = DB.query_single("SELECT value FROM site_settings WHERE name = 'general_category_id'")
+ general_category_id =
+ DB.query_single("SELECT value FROM site_settings WHERE name = 'general_category_id'")
return if general_category_id.blank? || general_category_id[0].to_i < 0
- default_composer_category = DB.query_single("SELECT value FROM site_settings where name = 'default_composer_category'")
+ default_composer_category =
+ DB.query_single("SELECT value FROM site_settings where name = 'default_composer_category'")
return if !default_composer_category.blank?
DB.exec(
"INSERT INTO site_settings(name, value, data_type, created_at, updated_at)
VALUES('default_composer_category', :setting, '16', NOW(), NOW())",
- setting: general_category_id[0].to_i
+ setting: general_category_id[0].to_i,
)
end
diff --git a/db/migrate/20221205225450_migrate_sidebar_site_settings.rb b/db/migrate/20221205225450_migrate_sidebar_site_settings.rb
index fc6a054f4d4..11e96430bee 100644
--- a/db/migrate/20221205225450_migrate_sidebar_site_settings.rb
+++ b/db/migrate/20221205225450_migrate_sidebar_site_settings.rb
@@ -2,32 +2,32 @@
class MigrateSidebarSiteSettings < ActiveRecord::Migration[7.0]
def up
- previous_enable_experimental_sidebar_hamburger = DB.query_single(
- "SELECT value FROM site_settings WHERE name = 'enable_experimental_sidebar_hamburger'"
- )[0]
+ previous_enable_experimental_sidebar_hamburger =
+ DB.query_single(
+ "SELECT value FROM site_settings WHERE name = 'enable_experimental_sidebar_hamburger'",
+ )[
+ 0
+ ]
- previous_enable_sidebar = DB.query_single(
- "SELECT value FROM site_settings WHERE name = 'enable_sidebar'"
- )[0]
+ previous_enable_sidebar =
+ DB.query_single("SELECT value FROM site_settings WHERE name = 'enable_sidebar'")[0]
value =
case [previous_enable_experimental_sidebar_hamburger, previous_enable_sidebar]
- when ['t', 't'], ['t', nil]
+ when %w[t t], ["t", nil]
"sidebar"
- when ['t', 'f']
+ when %w[t f]
"header dropdown"
- when ['f', 't'], ['f', 'f'], ['f', nil]
+ when %w[f t], %w[f f], ["f", nil]
"legacy"
- when [nil, 't'], [nil, 'f'], [nil, nil]
+ when [nil, "t"], [nil, "f"], [nil, nil]
nil
end
- if value
- execute(<<~SQL)
+ execute(<<~SQL) if value
INSERT INTO site_settings (name, data_type, value, created_at, updated_at)
VALUES ('navigation_menu', 8, '#{value}', now(), now())
SQL
- end
end
def down
diff --git a/db/migrate/20221212225921_enable_sidebar_and_chat.rb b/db/migrate/20221212225921_enable_sidebar_and_chat.rb
index 0edf7a46da8..83b365dd49d 100644
--- a/db/migrate/20221212225921_enable_sidebar_and_chat.rb
+++ b/db/migrate/20221212225921_enable_sidebar_and_chat.rb
@@ -10,7 +10,7 @@ class EnableSidebarAndChat < ActiveRecord::Migration[7.0]
SQL
# keep sidebar legacy and chat disabled for for existing sites
- if result.first['created_at'].to_datetime < 1.hour.ago
+ if result.first["created_at"].to_datetime < 1.hour.ago
execute <<~SQL
INSERT INTO site_settings(name, data_type, value, created_at, updated_at)
VALUES('chat_enabled', 5, 'f', NOW(), NOW())
diff --git a/db/post_migrate/20220214224506_reset_custom_emoji_post_bakes_version_secure_fix.rb b/db/post_migrate/20220214224506_reset_custom_emoji_post_bakes_version_secure_fix.rb
index 90cf8d17931..1a2c3accd68 100644
--- a/db/post_migrate/20220214224506_reset_custom_emoji_post_bakes_version_secure_fix.rb
+++ b/db/post_migrate/20220214224506_reset_custom_emoji_post_bakes_version_secure_fix.rb
@@ -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
diff --git a/db/post_migrate/20220302171443_rebake_old_avatar_service_urls.rb b/db/post_migrate/20220302171443_rebake_old_avatar_service_urls.rb
index 84e70066b71..63a65e8ce6a 100644
--- a/db/post_migrate/20220302171443_rebake_old_avatar_service_urls.rb
+++ b/db/post_migrate/20220302171443_rebake_old_avatar_service_urls.rb
@@ -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
diff --git a/db/post_migrate/20220325064954_make_some_bookmark_columns_nullable.rb b/db/post_migrate/20220325064954_make_some_bookmark_columns_nullable.rb
index 90905d34af9..dd2d3b45927 100644
--- a/db/post_migrate/20220325064954_make_some_bookmark_columns_nullable.rb
+++ b/db/post_migrate/20220325064954_make_some_bookmark_columns_nullable.rb
@@ -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
diff --git a/db/post_migrate/20220401140745_drop_category_required_tag_group_columns.rb b/db/post_migrate/20220401140745_drop_category_required_tag_group_columns.rb
index fb7abd769cc..b203db0d17c 100644
--- a/db/post_migrate/20220401140745_drop_category_required_tag_group_columns.rb
+++ b/db/post_migrate/20220401140745_drop_category_required_tag_group_columns.rb
@@ -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
diff --git a/db/post_migrate/20220621164914_drop_flair_url_from_groups.rb b/db/post_migrate/20220621164914_drop_flair_url_from_groups.rb
index 8f2f57f1147..c66cfd036f3 100644
--- a/db/post_migrate/20220621164914_drop_flair_url_from_groups.rb
+++ b/db/post_migrate/20220621164914_drop_flair_url_from_groups.rb
@@ -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
diff --git a/db/post_migrate/20221026035440_security_log_out_invite_redemption_invited_users.rb b/db/post_migrate/20221026035440_security_log_out_invite_redemption_invited_users.rb
index e87a27e3b0c..9f627d10ff3 100644
--- a/db/post_migrate/20221026035440_security_log_out_invite_redemption_invited_users.rb
+++ b/db/post_migrate/20221026035440_security_log_out_invite_redemption_invited_users.rb
@@ -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
diff --git a/db/post_migrate/20221108032233_drop_old_bookmark_columns_v2.rb b/db/post_migrate/20221108032233_drop_old_bookmark_columns_v2.rb
index a0ad3fd3d1f..7860e1546f2 100644
--- a/db/post_migrate/20221108032233_drop_old_bookmark_columns_v2.rb
+++ b/db/post_migrate/20221108032233_drop_old_bookmark_columns_v2.rb
@@ -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