Small plates of your production data.

tapas takes a sample of a MySQL or Postgres database and writes it to a SQL file or straight into another database. Every reference stays intact, so nothing points at a row that isn't there.

brew install xjunior/tap/tapas

Or grab a binary for Linux or macOS from the releases.

Why bother?

Everyone wants a database that feels like production without being production. A full dump is too big. LIMIT 1000 leaves orders pointing at users who didn't make the cut. And the script someone wrote two years ago died at the third migration.

With tapas you describe what to take, and it works out the rest: the order, the parallelism, and the rows other rows need.

Samplers say what to take

Plain SQL, a time window, a row limit, or "whatever belongs to the rows I already have".

References hold

deps pulls in what your rows point at. tapas also reads the source's foreign keys, so you only write the links the schema doesn't state.

One config, many sizes

--since '2 weeks' for a laptop, --since '3 months' for a review environment.

No personal data

Emails, names and SSNs become fakes that look real. The same email gets the same fake everywhere, so joins still join.

Fast

Independent tables and chunks run at once over read-only connections, streaming rows instead of loading them.

Look before you leap

--plan prints every query without touching the database.

Quick start

Say what you want, then check the plan, run it and load it.

samplers:
  - table: countries
    limit: all

  - table: orders
    limit: { since: created_at }
    deps:
      user_id: users.id

  - table: users
    where: admin = 1
    limit: all
    deps:
      country_id: countries.id

  - table: line_items
    of:
      order_id: orders.id
# look at the queries first
tapas tapas.yml --since '2 weeks' --plan

# write a SQL file
tapas tapas.yml --since '2 weeks' \
  --source mysql://user:pass@host/shop \
  -o sample.sql

# or pour it into another database
tapas tapas.yml --since '2 weeks' \
  --source mysql://user:pass@host/shop \
  --target mysql://root@localhost/shop_dev

Postgres works the same way with postgres:// URLs. tapas writes INSERTs only, so the target needs its schema already.

Keep the data, lose the people

Rules match column names and say what the values become. Everything else is copied as is, so check new columns against your rules.

sanitize:
  columns:
    "*email*": { fake: email }
    "*notes*": { value: Redacted }
  tables:
    users:
      ssn: { fake: ssn }
      login: { template: "user_{id}" }

Documentation