You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have a separate database for PaperTrail::Version and PaperTrail::VersionAssociation but we can't find a good way of implementing this.
Currently we are doing something like this:
require'paper_trail/version'require'paper_trail/version_association'modulePaperTrailclassVersion < ActiveRecord::Base# Rails requires a abstract class for no reason to call connects_to, but we# can't use one since the class will mismatch with the gem.self.abstract_class=trueconnects_todatabase: {normal: :auditing,dirty: :auditing}self.abstract_class=falseself.table_name="auditing.versions"endendmodulePaperTrailclassVersionAssociation < ActiveRecord::Base# Rails requires a abstract class for no reason to call connects_to, but we# can't use one since the class will mismatch with the gem.self.abstract_class=trueconnects_todatabase: {normal: :auditing,dirty: :auditing}self.abstract_class=falseself.table_name="auditing.version_associations"endend
Although, this creates an issue by creating two separate connection pools:
Those could be replaced by something like or something:
PaperTrailAssociationTracking.model_class
In our use case, we don't need different classes per model (as supported by paper_trail) but for the application as a whole, which facilitates things here a little bit.
WDYT?
The text was updated successfully, but these errors were encountered:
But then by using the two connection pools, FKs doesn't work in a transaction because Rails will use two separate connections thinking that they are two separate DBs.
Hi there!
We have a separate database for
PaperTrail::Version
andPaperTrail::VersionAssociation
but we can't find a good way of implementing this.Currently we are doing something like this:
Although, this creates an issue by creating two separate connection pools:
Therefore it creates an issue with our FK between
version_associations
andversions
.To share the connection pool, we need to create an abstract class and inherit from it, like this:
While we can replace the
Version
class with a config option like this:There's no similar option for this gem.
There are explicit class directly to
PaperTrail::VersionAssociation
in the gem that could be replaced to use a config option, i.e.:paper_trail-association_tracking/lib/paper_trail_association_tracking/reifiers/has_and_belongs_to_many.rb
Line 11 in c8e8b2c
paper_trail-association_tracking/lib/paper_trail_association_tracking/reifiers/has_many.rb
Line 103 in c8e8b2c
Those could be replaced by something like or something:
In our use case, we don't need different classes per model (as supported by paper_trail) but for the application as a whole, which facilitates things here a little bit.
WDYT?
The text was updated successfully, but these errors were encountered: