-
Notifications
You must be signed in to change notification settings - Fork 4
Multi Database Behavior
Ngan Pham edited this page May 6, 2026
·
2 revisions
FixtureKit stores restore SQL keyed by model class name and replays per model connection pool.
At replay time, FixtureKit:
- Constantizes cached model names.
- Groups statements by each model's
connection_pool(the stable identity for a database, role-aware). - Checks out a connection via
pool.with_connectionfor the duration of the replay on that pool. - Replays table clears + inserts inside that connection.
This routes writes to the same database handlers used by those models (for example, primary, analytics, etc.).
During generation, FixtureKit subscribes to sql.active_record and tracks models for names matching write operations (Insert/Upsert/Create/Update/Delete/Destroy and supported bulk variants).
- Ensure your fixture generation touches the same models your tests need.
- If a model's data is expected but missing, verify that model had a write during generation.