about summary refs log tree commit diff
path: root/db/migrate
diff options
context:
space:
mode:
authorReverite <github@reverite.sh>2019-06-09 16:54:21 -0700
committerReverite <github@reverite.sh>2019-06-09 16:54:21 -0700
commit3614718bc91f90a6dc19dd80ecf3bc191283c24e (patch)
treead35f4dbe92fdbc3f95881d6be3d4f9b29d4a704 /db/migrate
parent846a09a7435fb9eb435e9950175ee0e696ed4909 (diff)
parente16c8fbc7a2b5a866960a87bc8c950ad0d38f61b (diff)
Merge branch 'glitch' into production
Diffstat (limited to 'db/migrate')
-rw-r--r--db/migrate/20171005102658_create_account_moderation_notes.rb2
-rw-r--r--db/migrate/20171010023049_add_foreign_key_to_account_moderation_notes.rb2
-rw-r--r--db/migrate/20171118012443_add_moved_to_account_id_to_accounts.rb2
-rw-r--r--db/migrate/20180402040909_create_report_notes.rb4
-rw-r--r--db/migrate/20180707193142_migrate_filters.rb2
-rw-r--r--db/migrate/20190529143559_preserve_old_layout_for_existing_users.rb17
6 files changed, 23 insertions, 6 deletions
diff --git a/db/migrate/20171005102658_create_account_moderation_notes.rb b/db/migrate/20171005102658_create_account_moderation_notes.rb
index 974ed9940..010b94586 100644
--- a/db/migrate/20171005102658_create_account_moderation_notes.rb
+++ b/db/migrate/20171005102658_create_account_moderation_notes.rb
@@ -8,6 +8,6 @@ class CreateAccountModerationNotes < ActiveRecord::Migration[5.1]
       t.timestamps
     end
 
-    add_foreign_key :account_moderation_notes, :accounts, column: :target_account_id
+    safety_assured { add_foreign_key :account_moderation_notes, :accounts, column: :target_account_id }
   end
 end
diff --git a/db/migrate/20171010023049_add_foreign_key_to_account_moderation_notes.rb b/db/migrate/20171010023049_add_foreign_key_to_account_moderation_notes.rb
index fc1e1ab91..cdcd15934 100644
--- a/db/migrate/20171010023049_add_foreign_key_to_account_moderation_notes.rb
+++ b/db/migrate/20171010023049_add_foreign_key_to_account_moderation_notes.rb
@@ -1,5 +1,5 @@
 class AddForeignKeyToAccountModerationNotes < ActiveRecord::Migration[5.1]
   def change
-    add_foreign_key :account_moderation_notes, :accounts
+    safety_assured { add_foreign_key :account_moderation_notes, :accounts }
   end
 end
diff --git a/db/migrate/20171118012443_add_moved_to_account_id_to_accounts.rb b/db/migrate/20171118012443_add_moved_to_account_id_to_accounts.rb
index 0c8a894cc..586ef6f02 100644
--- a/db/migrate/20171118012443_add_moved_to_account_id_to_accounts.rb
+++ b/db/migrate/20171118012443_add_moved_to_account_id_to_accounts.rb
@@ -1,6 +1,6 @@
 class AddMovedToAccountIdToAccounts < ActiveRecord::Migration[5.1]
   def change
     add_column :accounts, :moved_to_account_id, :bigint, null: true, default: nil
-    add_foreign_key :accounts, :accounts, column: :moved_to_account_id, on_delete: :nullify
+    safety_assured { add_foreign_key :accounts, :accounts, column: :moved_to_account_id, on_delete: :nullify }
   end
 end
diff --git a/db/migrate/20180402040909_create_report_notes.rb b/db/migrate/20180402040909_create_report_notes.rb
index 732ddf825..429cb4534 100644
--- a/db/migrate/20180402040909_create_report_notes.rb
+++ b/db/migrate/20180402040909_create_report_notes.rb
@@ -8,7 +8,7 @@ class CreateReportNotes < ActiveRecord::Migration[5.1]
       t.timestamps
     end
 
-    add_foreign_key :report_notes, :reports, column: :report_id, on_delete: :cascade
-    add_foreign_key :report_notes, :accounts, column: :account_id, on_delete: :cascade
+    safety_assured { add_foreign_key :report_notes, :reports, column: :report_id, on_delete: :cascade }
+    safety_assured { add_foreign_key :report_notes, :accounts, column: :account_id, on_delete: :cascade }
   end
 end
diff --git a/db/migrate/20180707193142_migrate_filters.rb b/db/migrate/20180707193142_migrate_filters.rb
index 10b814c0f..067c53357 100644
--- a/db/migrate/20180707193142_migrate_filters.rb
+++ b/db/migrate/20180707193142_migrate_filters.rb
@@ -41,7 +41,7 @@ class MigrateFilters < ActiveRecord::Migration[5.2]
         t.timestamps
       end
 
-      add_foreign_key :glitch_keyword_mutes, :accounts, on_delete: :cascade
+      safety_assured { add_foreign_key :glitch_keyword_mutes, :accounts, on_delete: :cascade }
     end
 
     CustomFilter.where(irreversible: true).find_each do |filter|
diff --git a/db/migrate/20190529143559_preserve_old_layout_for_existing_users.rb b/db/migrate/20190529143559_preserve_old_layout_for_existing_users.rb
new file mode 100644
index 000000000..72b7c609d
--- /dev/null
+++ b/db/migrate/20190529143559_preserve_old_layout_for_existing_users.rb
@@ -0,0 +1,17 @@
+class PreserveOldLayoutForExistingUsers < ActiveRecord::Migration[5.2]
+  disable_ddl_transaction!
+
+  def up
+    # Assume that currently active users are already using the layout that they
+    # want to use, therefore ensure that it is saved explicitly and not based
+    # on the to-be-changed default
+
+    User.where(User.arel_table[:current_sign_in_at].gteq(1.month.ago)).find_each do |user|
+      next if Setting.unscoped.where(thing_type: 'User', thing_id: user.id, var: 'advanced_layout').exists?
+      user.settings.advanced_layout = true
+    end
+  end
+
+  def down
+  end
+end