djezzzl/database_consistency

skip ForeignKeyChecker for rails 6+ multiple databases setup

Closed this issue · 3 comments

ForeignKeyChecker should ignore when the underlying association tables belong to different databases, since a foreign key cannot be defined here.

production:
  primary:
    database: my_primary_database
  animals:
    database: my_animals_database
    migrations_paths: db/animals_migrate
class User < ApplicationRecord
  has_many :dogs
end

class AnimalsRecord < ApplicationRecord
  self.abstract_class = true
  connects_to database: { writing: :animals, reading: :animals }
end

class Dog < AnimalsRecord
  belongs_to :user
end

ForeignKeyChecker fail Dog User should have foreign key in the database

Hello @uxxman , thank you for sharing this!

Would you like to contribute and provide a fix?

hey @djezzzl, i took a stab at it here #116

fixed in #116 . Closing