How to use DataMask

1. Dump the schema — not the data

pg_dump --schema-only --no-owner --no-privileges "$DATABASE_URL" > schema.sql

Paste schema.sql (or choose the file) in your database's page. Rails structure.sql and plain migration files in order work too.

2. Review the plan

Ask the AI for a plan, then go through it: every column shows its method, why, and whether it came from the AI or from you. Change any method; only methods that fit the column are offered. Columns marked "Not reviewed" are kept as they are until someone decides.

3. Run the script on a copy

createdb staging && pg_dump "$DATABASE_URL" | psql -q staging
psql -v ON_ERROR_STOP=1 -d staging -f mask.sql
psql -d staging -f check.sql   # every "left" must be 0

mask.sql is one transaction: it makes a random salt that disappears when it ends, then one UPDATE per table. If it changes key columns other tables point at, it pauses foreign key checks for that transaction (needs a superuser, or rds_superuser on Amazon RDS) — the values still match because the same input gets the same fake value.

The methods

Fake email
u + 16 hex characters @example.invalid — from a salted hash, so the same address always gets the same fake one in a run; stays unique.
Hashed identifier
user_ + 16 hex characters — usernames, handles, external ids; stays unique.
Fake names, phone, street, postal code
Picked from fixed lists or digits by a salted hash of the value (phone numbers in the +1 555 01 range, which can’t be real).
Keep the year only
Dates become 1 January of the same year — birth dates.
Network part only
IPv4 addresses keep their /16 network (81.12.0.0); IPv6 its /48.
Redact text
[redacted] — notes, messages, bios, anything people type.
Random secret
32 random hex characters — password hashes, tokens, API keys. Logins on the copy stop working.
Rounded with noise
Within ±10% — salaries and other personal amounts.
Empty JSON, Set to NULL, Keep
For JSON with personal data, for columns you don’t need, and for everything that isn’t personal.

What it doesn't do

It doesn't look at your data, so it can't find personal data hidden in a column named "misc" — read the plan. It masks what the plan says; deciding whether a copy is anonymous enough for your purpose stays with you.