]> cat aescling's git repositories - mastodon.git/commitdiff
Make some migration script more robust (fixes #8007) (#8170)
authorThibG <thib@sitedethib.com>
Sat, 11 Aug 2018 16:00:41 +0000 (18:00 +0200)
committerEugen Rochko <eugen@zeonfederated.com>
Sat, 11 Aug 2018 16:00:41 +0000 (18:00 +0200)
Include a dummy Account class in the migration script containing only the
attributes relevant to the migration in order to not rely as much on the
codebase being in sync with the database schema.

db/migrate/20180528141303_fix_accounts_unique_index.rb

index 96cee37f9cba16c0b24f8777aca210888641836f..624ea229e4fd79fc49db92ce703528b6aa8507ae 100644 (file)
@@ -1,4 +1,13 @@
 class FixAccountsUniqueIndex < ActiveRecord::Migration[5.2]
+  class Account < ApplicationRecord
+    # Dummy class, to make migration possible across version changes
+    has_one :user, inverse_of: :account
+
+    def local?
+      domain.nil?
+    end
+  end
+
   disable_ddl_transaction!
 
   def up