about summary refs log tree commit diff
path: root/db
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2019-06-03 14:54:30 +0200
committerThibaut Girka <thib@sitedethib.com>2019-06-03 14:54:30 +0200
commit76918554a6898f9b94d4ffde07face01754fd058 (patch)
treefa394c02128610793353c0a6ba8363d814147ea4 /db
parent35c4ff07f4d61aaf7ade2ae17060298d62b3f643 (diff)
parentf2f5c1bd6d37ec2ba7d0f98a3c0f8fead6b78f1d (diff)
Merge remote-tracking branch 'upstream/master' into glitch-soc/merge-upstream
Conflicts:
- Gemfile.lock
- config/webpack/rules/css.js
- package.json
- yarn.lock
Diffstat (limited to 'db')
-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/20190529143559_preserve_old_layout_for_existing_users.rb17
-rw-r--r--db/schema.rb2
5 files changed, 21 insertions, 4 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/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
diff --git a/db/schema.rb b/db/schema.rb
index 96961c812..aa02be55f 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,7 +10,7 @@
 #
 # It's strongly recommended that you check this file into your version control system.
 
-ActiveRecord::Schema.define(version: 2019_05_19_130537) do
+ActiveRecord::Schema.define(version: 2019_05_29_143559) do
 
   # These are extensions that must be enabled in order to support this database
   enable_extension "plpgsql"