Nikasa, home Request an invite
DocsStart from real data

Start from real data

By default every run starts its databases empty and each build migrates them itself. When your requests need data to exist, or you want the path a real deploy takes, start from a saved state.

On this page

There are two ways to start from a saved state:

Start from a seed #

Give Nikasa a dump or a command:

shell
nk compare myapp:old myapp:new out --seed-dump seed.dump
nk compare myapp:old myapp:new out --seed "rails db:seed"
nk compare myapp:old myapp:new out --seed "python manage.py loaddata fixtures.json"
Flag What it takes
--seed-dump <dump> A Postgres dump (pg_dump -Fc, or plain SQL made with --no-owner) or a MySQL or MariaDB dump (mysqldump), as a path, a link or an s3:// path.
--seed "<command>" A command that runs once in your app's container after the old build has started, as docker compose run app <command> would. It works for every database.

What Nikasa does with it #

  1. Once, from the old build, it restores the dump, starts the old build so its migrations run, then runs the command.
  2. It keeps the result. It stops each database cleanly and keeps its data folder as a Docker volume named nk-golden-<hash>. The report calls this saved state a golden.
  3. Every run of both builds starts from a copy of it, and the new build's migrations run on top, as in a deploy.

The hash covers the database images and settings in your compose file, the old build's image and the seed. A change to any of them builds a new one. Otherwise the saved state is reused across compares.

Remove a saved state #

shell
docker volume rm nk-golden-<hash>

Seeds and packs #

nk record with a seed writes it into the pack's state.json: the dump's location and SHA-256, or the command. nk compare --pack then starts from the same state, and refuses a dump whose bytes have changed.

Start from the old build's migrated database #

shell
nk compare myapp:old myapp:new out --start-migrated

The old build starts once on empty databases and migrates them, and each database is kept the same way. Every run of both builds then starts from a copy.

  • The old runs migrate nothing.
  • The new runs migrate from the old schema to the new one, which is the path a real deploy takes.

A fresh install is still checked #

With this flag, Nikasa adds one more new run from empty databases. What it did differently from the migrated new runs is listed under fresh install of the new build, for information. It never counts, and a fresh install that fails to start is listed the same way.

What it could hide #

  • A migration that breaks only on an empty database. The fresh install run is the check for that.
  • Time baked into the saved rows, such as expiring tokens or trial periods, which age as the state is reused.
  • Secrets or install ids generated once at install time, which every run then shares.

The report's provenance says when the state was built.

Limits #

  • It covers Postgres, MySQL, MariaDB, Mongo, Redis and Valkey services. A database inside the app's own volume, such as SQLite or H2, is not kept.
  • --start-migrated is refused when the new build runs a database on another image than the old one, as a data folder does not carry across engine versions. To check a database upgrade, compare from empty databases: see Check an upgrade.
  • With --seed or a pack that has a seed, the state already holds the old build's migrations, so the flag is refused there.

Next steps #

Written for nk 0.3.14. Something wrong or unclear? Write to hello@nikasa.dev.