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
Since the connection attribute is defined on models, is it possible to use a model with multiple databases at once; for example a production and testing database? And would it be possible to use multiple models within a transaction, since it seems based on #379 the transaction feature is accessed from a model?
The text was updated successfully, but these errors were encountered:
is it possible to use a model with multiple databases at once
Not the way you're thinking at least. You would be able to register the connection differently based on ENV vars for example. I.e. parameterize Granite::Connections << Granite::Adapter::Mysql.new("mysql", "YOUR_DATABASE_URL")
would it be possible to use multiple models within a transaction
I think so yea. The transaction instance is obtained from a model's adapter. IMO this isn't ideal but it is what it is. I'm doing just that for another project of mine. Saving three objects within a transactions using save!. If one of them fails to save the previous one's don't get committed.
By using a model with multiple databases I meant at the same time, not just with the same code. But I guess that could probably be accomplished by subclassing the model and just overriding the connection?
Since the
connection
attribute is defined on models, is it possible to use a model with multiple databases at once; for example a production and testing database? And would it be possible to use multiple models within a transaction, since it seems based on #379 the transaction feature is accessed from a model?The text was updated successfully, but these errors were encountered: