Skip to content

Multi Database Behavior

Ngan Pham edited this page Feb 24, 2026 · 1 revision

Multi-Database Behavior

FixtureKit stores restore SQL keyed by model class name and replays per model connection.

Why This Works for Multi-DB

At replay time, FixtureKit:

  1. Constantizes cached model names.
  2. Uses each model's connection.
  3. Groups SQL statements by connection.
  4. Replays table clears + inserts inside that connection.

This routes writes to the same database handlers used by those models (for example, primary, analytics, etc.).

Change Tracking Input

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).

Practical Guidance

  • 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.

Clone this wiki locally