Skip to the lesson
CivOps AI Academy · F04Data That Looks Like Your Plant: Synthetic Data in Postgres
0%

Chapter 1 · Session 6

A second project for made-up data

Every screen from here on is built and tested before real data flows. It needs data that behaves like your plant, and none of it may be real. This chapter creates a second, free Supabase project that only ever holds made-up data, and collects the five facts that make the data look like your plant.

30 min2 stepsBrowser and one email

By the end of this chapter you can

  • Say why development and tests use made-up data only, kept in a separate project from production.
  • Create the development project {{sbDevProject}} on the free plan, with its password in the password manager.
  • Collect the five facts from the plant that make made-up data realistic.

Why not copy the real data?

Real plant data carries people's names, customer part numbers and sometimes recipes. Copied into a development database it is exposed to everything that touches development: builders, test runs, preview links and AI agents. Removing the names is not enough: NIST's guidance on de-identification explains how records can often be traced back to people by combining the fields that remain [1]. The rule in this course is simple: real data stays in production; the CI check and the development project hold made-up data only, and made-up data never enters production.

Where made-up data belongsThree places: the CI check and the development project hold only made-up data from the seed; the production project holds real plant data. Code moves from left to right; the seed never runs on production and real data never moves left. CI checkfresh database, every PRmigrations, then the seedDevelopment projectmade-up data onlyscreens are built on itProduction projectreal plant datareal people, real decisionscode moves rightcode moves rightthe seed never runs here;real data never moves leftSame migrations everywhere; only the rows differ.
Where made-up data belongs. The same migrations build all three; only the rows differ. Code moves towards production. The seed never runs there, and real data never moves back.

Why a second project, and not the production one

The production project acme-platform-prod will hold the plant's records. Keeping made-up data in a different project means a mistake with test data can never touch a real record, and nobody ever has to guess which rows are real. Supabase's free plan allows two active projects, so the second one costs nothing [2]. One thing we learned the hard way: on the platform we built, a "reset the database" command run to fix a migration error used the everyday login against a shared development database and wiped it, including another app's user accounts. So in this course nothing is ever reset except a database on your own machine or in CI, and development and production never share a database.

Key or secretWhat it unlocksWhere it livesWho holds itNever
acme-platform-dev database passwordFull control of the development databaseCompany password manager: Supabase: acme-platform-dev database passwordBoth ownersPasted into Claude Code, a file or a chat
acme-platform-dev project reference (tsrqponmlkjihgfedcba)Nothing on its own: it names the project in addresses and commandsdocs/KEYS.md and Your namesAnyone on the projectConfused with production's (abcdefghijklmnopqrst)
Supabase access token (from npx supabase login)The CLI acting as you, on both projectsYour computer only, stored by the CLIEach person for themselvesShared or copied anywhere
Step 1

Create the development project

10 minutes

Why

Made-up data needs a home that is not production. Creating it in the browser yourself, as in Session 1, means the company owns it, its password goes straight into the password manager, and you know its reference by heart before any command uses it. A free project is enough: it holds only made-up data and can be rebuilt from the repository at any time.

Do this

Open

https://supabase.com/dashboard/new

Choose the Acme Bottling organisation if it is still on the Free plan. Project name acme-platform-dev, the same region as production (us-east-2). If the organisation is on Pro, a second project there is billed: create a separate organisation instead (for example Acme Bottling development, plan Free, both owners as Owner) and put the project there. Prices change: check the pricing page on the day.

On Database password, choose Generate a password and copy it straight into the password manager as Supabase: acme-platform-dev database password before you press Create new project.

When the project is ready, copy the 20 letters after /project/ in the address bar into Development project reference in Your names. Then check it opens the right project:

Open

https://supabase.com/dashboard/project/tsrqponmlkjihgfedcba/settings/general

This must show acme-platform-dev. If it shows acme-platform-prod, you typed the production reference: fix Your names now, because every command in this session uses it.

You will see recreated screen

supabase.com/dashboard/new
Create a new project
OrganizationAcme Bottling (Free) ▾1
Project nameacme-platform-dev
Database password••••••••••••••••2
Generate a password
Regionus-east-2 ▾
Create new project
Creating the development project: free plan, same region as production, password into the password manager first.
  1. A free organisation, so the project costs nothing. On Pro, a second project is billed.
  2. Into the password manager before you press Create: it is not shown again.

You will see recreated screen

supabase.com/dashboard/projects
Projects
acme-platform-prodabcdefghijklmnopqrst · real plant data1
acme-platform-devtsrqponmlkjihgfedcba · made-up data only2
The two projects side by side in the dashboard. Learn to tell them apart by name and reference.
  1. Production. The seed never runs here.
  2. Development. Everything in this session runs here.

Check it worked

The settings link above opens acme-platform-dev; its password is in the password manager; Development project reference in Your names is not the same as the production reference.

Fastest path

Invite owner two to the organisation now (Organization settings, Team, Invite, role Owner), as in Session 1: one visit instead of two.

If it goes wrong

Supabase says you have reached the limit of free projects

The free plan allows two active projects for each organisation owner. Pause or delete an old personal test project, or create the development project in an organisation where you have no other free project. Never put made-up data in the production project to save a slot.

The development project shows as paused a week later

Free projects pause after a week with no activity. Open it and choose Restore project. Nothing is lost, and the seed can rebuild every row anyway.

I did not save the database password

Reset it: Project Settings, Database, Reset database password, straight into the password manager. Nothing else uses it yet.

Realistic is not random

Random numbers between 0 and 100 make every screen look fine and test nothing. Made-up data is useful only if it behaves like the plant in five ways:

PropertyWhat it meansStamping plant
VolumeAs many rows as a real quarter makesAbout 1,560 lots and 6,240 inspections in 13 weeks
DistributionValues spread the way the process spreadsFlange height around 12.00 mm, most within ±0.06 mm [3]
RhythmShifts, weekends, die changesTwo shifts on weekdays; more checks in the hour after a die change
Rare eventsThe bad days, at about the real rateAbout 1 first piece in 20 fails; a few holds a week
MistakesLate, missing and corrected entriesAbout 5% typed in late; a few corrections; a press down for a shift
A day of inspectionsInspections per hour over one day: none at night, about six an hour on two shifts, with peaks of nine in the hours with a die change. 00:0003:0006:0009:0012:0015:0018:0021:0024:00Day shift 06:00 to 14:30Second shift 14:30 to 23:00Six presses inspected hourly; amber hours include a die change and its first-piece checks. Nothing runs at night.
The rhythm of a day. Two shifts on weekdays, about six inspections an hour across six presses, more in the hours with a die change, and nothing at night.
Step 2

Ask the plant for five facts

10 minutes, plus their reply

Why

You do not need the real data to make realistic data: you need five facts that the person who makes the decision (Session 2) knows from memory. Asking in writing, now, means the seed is written once from their numbers instead of rewritten after they see it and say it looks nothing like their plant.

Do this

Email to send (copy, then fill in the name)
To: <the person who makes the decision>
Subject: Five numbers for the Acme Bottling platform's test data

We are building the platform's screens on made-up data before any real data goes in. To make it behave like Cleveland, could you give me your best figures (rough is fine):

1. The presses, lines or cells, and which shifts they run (and on which days).
2. How many lots each makes in a shift.
3. For the key measurement: the target, the limits, and how much it usually varies.
4. How often the bad event happens: failed first pieces, holds or breakdowns, per week.
5. What usually goes wrong with the records: entries typed in late, missing results, corrections.

Ten minutes is plenty. I will show you the result before anyone builds on it.

You will see recreated screen

Your email
Re: Five numbers for the Acme Bottling platform's test data
1. Six presses on two lines, two shifts (06:00 to 14:30 and 14:30 to 23:00), Monday to Friday.1
2. Two lots per press per shift, sometimes three on short runs.
3. Flange height 12.00 mm, limits 11.90 to 12.10. Usually within 0.05; first pieces worse.
4. About 1 first piece in 20 fails. Five to eight holds a week. Press 4 is down a shift most weeks.
5. Night-shift results get typed in late, maybe one in twenty. A few corrections a week.2
A reply with the five facts. Paste it, unchanged, into the prompt in Step 3.
  1. Their words, not yours: these become the seed's settings.
  2. The mistakes matter as much as the averages: screens must cope with them.

Check it worked

You have a written reply with all five facts, or a date when you will get it.

Fastest path

If they are on the floor, ask the five questions in person and type their answers into the email yourself; send it to them as a record.

If it goes wrong

They offer to send a spreadsheet of last month's real results instead

Thank them and decline: real records never go into the repository or the development project. Ask only for the five summary numbers.

Knowledge check

Why not copy production data into the development project with the names removed?

Knowledge check

Where does made-up data live?

References

  1. NIST SP 800-188: De-Identifying Government Datasets. https://csrc.nist.gov/pubs/sp/800/188/final
  2. Supabase pricing (free plan limits). https://supabase.com/pricing
  3. NIST/SEMATECH e-Handbook of Statistical Methods. https://www.itl.nist.gov/div898/handbook/

Chapter 2 · Session 6

The seed: made-up data relative to today, proven in CI

One prompt gives you supabase/seed.sql, which generates a quarter of plant data ending at the moment it runs; every row marked as made up and removable in one command; the counts later sessions rely on, proven in the schema check on every pull request; and a guarded command that loads it into the development project and nowhere else.

35 min2 stepsThe seed testing protocol

By the end of this chapter you can

  • Have Claude Code write the seed, its tests, the CI change and the guarded seed command in one pull request.
  • Know the three problems the seed is built to avoid: data that ages, data that passes for real, and counts that do not match later exercises.
  • Review the seed through Claude Code's explanation, against fixed questions.

Three ways made-up data goes wrong

Each of these happened when we built our own platform. The seed in this session is written so none of them can happen to yours:

What we sawWhyWhat the seed does
A week after seeding, "this shift" and "last 8 hours" panels went blank. Eleven days on, the newest seeded batch was 10.9 days oldThe seed wrote fixed datesIt reads the clock once and places the newest record at that moment, keeping every gap between records the same. Re-running it brings the data up to date
Nobody could tell demo numbers from real ones, and later nobody was sure which rows were safe to deleteSeed data looks exactly like real data unless it is markedEvery row belongs to a site whose code starts with syn, every visible name starts SYNTHETIC ·, part numbers start SYN-, and one command removes exactly those rows
A later exercise said "you should see 12 open work orders" and the learner saw 9Exercises were written against counts the seed never madeThe seed's header lists every count later sessions rely on, and a test fails if the seed stops making them

Three Postgres tools do the work

FunctionWhat it doesUsed for
generate_series(a, b)One row for each number from a to b [1]Days, shifts, presses, lots, hours
random_normal(mean, sd)A value from a normal distribution, Postgres 16 and later [2]Measurements that spread like the process
setseed(x)Fixes the random sequence [2]The same values every time the file runs, so a failing test fails the same way twice
Generated measurements against the limitsA bell-shaped histogram of 400 generated flange heights centred on 12.00 mm, with the lower limit at 11.90 mm and the upper limit at 12.10 mm marked. lower limit 11.90upper limit 12.10nominal 12.0011.9011.9512.0012.0512.10400 generated values, mean 12.00 mm, standard deviation 0.03 mm
Generated results, drawn to scale. 400 values from a normal distribution, mean 12.00 mm, standard deviation 0.03 mm: almost all inside the limits, as on a stable press.
Die wear in the generated dataA run chart of forty hourly values that drift upward as the die wears, until one crosses the upper limit and the lot is held. upper limitlower limitnominalfirst value over the limit: holdHours since the last die change →
Die wear in made-up data. Hourly values drift up as the die wears until one crosses the upper limit: the moment a hold should happen. A screen built on this data shows the drift before it becomes a hold.
Step 3

One prompt: the seed, its tests, CI and the guarded seed command

15 minutes

Why

Writing the seed, the tests that prove its counts and markings, the CI change and the command that loads it in one pull request means the proof arrives with the data. It also locks the seed command away from Claude Code in the same change, so the only way made-up data reaches a real project is a person typing a command that checks which project it is.

Do this

Paste into Claude Code, after replacing the <...> part
Read docs/INTENT.md, docs/naming-standard.md, docs/SCHEMA-PLAN.md, every file in supabase/migrations/ and supabase/tests/, and .github/workflows/schema.yml.

The decision-maker's five facts, in their words:
<paste their reply>

On a new branch data/synthetic-seed:

1. supabase/seed.sql: made-up data for every table in the schema, from the five facts.
   - Guard first: if any lot or inspection exists at a site whose code does not start with "syn", stop with the error "seed.sql refused: this database holds real records".
   - Create a schema named synthetic (not exposed to the API; revoke everything from anon and authenticated) holding a function synthetic.remove() that deletes every made-up row and nothing else. It may disable a table's append-only trigger only inside that function, and only to delete rows of syn sites.
   - Start by calling synthetic.remove(), so running the file again replaces the data instead of adding to it.
   - Mark everything: two sites, codes "syn" (the main plant, from the five facts) and "synb" (a small second plant, so Session 8 can test that one site never sees another's rows); every visible name starts "SYNTHETIC · "; part numbers start "SYN-"; equipment codes and lot codes follow docs/naming-standard.md.
   - People: one made-up person per role in the schema, emails syn.<role>@example.com, with no password so they can never sign in, and memberships at the syn sites. Create them only if missing.
   - Time: read the clock once. Generate 13 weeks on the plant's calendar, then move every timestamp by one offset so the newest inspection is the moment of seeding. Every gap between related rows stays the same.
   - Realism: setseed first; generate_series for days, shifts, presses and lots; random_normal for measurements (Box-Muller if the Postgres version is below 16); a wider spread on first pieces; a slow upward drift as the die wears; holds at the first result outside the limits; about 5% of results typed in late (created_at more than an hour after recorded_at; if inspections has no created_at column, stop and tell me: that is a new migration, not something to work around); a few corrections as new rows that point to the row they correct and say why; one press down for a whole shift; a few results exactly on a limit; one hold reason of 300 characters.
   - A header comment: what the file makes, and "Counts later sessions rely on" with the exact number of sites, presses, lots, inspections, holds, corrections and people.

2. supabase/tests/seed.test.sql (pgTAP), proving: every count in the header; the newest inspection is less than one hour old; every row of every table with a site belongs to a syn site or to cle's reference rows from the migrations; every visible name is marked; no made-up person has a password; synthetic.remove() leaves no made-up row and changes no other row (compare a fingerprint of all other rows before and after); the guard refuses when a real lot exists. Every existing test must still pass with the data present.

3. CI: make sure supabase/config.toml has [db.seed] enabled with sql_paths = ["./seed.sql"], so the schema check loads the seed after the migrations before it runs the tests. If the workflow does not load it, add a step that does, against CI's own throwaway database only. npm run check:names must still pass.

4. scripts/seed-dev.mjs and "seed:dev": "node scripts/seed-dev.mjs" in package.json, Node.js only. It must refuse unless the target is the development project tsrqponmlkjihgfedcba, and refuse loudly if anything points at production abcdefghijklmnopqrst. It runs: npx supabase db query --linked --project-ref tsrqponmlkjihgfedcba --file supabase/seed.sql, then prints the counts. Add a short section "Made-up data" to docs/KEYS.md naming the development project acme-platform-dev (tsrqponmlkjihgfedcba) and where its password lives (password manager only), and how to run npm run seed:dev.

5. Add to the deny list in .claude/settings.json: Bash(npm run seed:dev:*), Bash(node scripts/seed-dev.mjs:*), Bash(npx supabase db query:*), Bash(npx supabase link:*). Do not remove any existing rule.

6. Do not connect to, link or change either Supabase project.

Push, open a pull request titled "Made-up data", wait for every check to finish (gh pr checks --watch), and tell me the result in plain words, with the counts from the header. If anything fails, fix the cause, not the test, and wait again before reporting.

You will see recreated screen

claude — acme-platform
☒ Write supabase/seed.sql (guard, synthetic.remove, generator)
☒ Write supabase/tests/seed.test.sql
☒ Seed in CI via [db.seed]
☒ scripts/seed-dev.mjs, docs/KEYS.md, deny rules
☐ Push and wait for checks
⏺ Write(supabase/seed.sql)
+-- Counts later sessions rely on (tested in supabase/tests/seed.test.sql):
+-- sites 2 (syn, synb) · presses 8 · lots 1,820 · inspections 7,311
+-- holds 81 · corrections 31 · people 7
+select setseed(0.42);
+select synthetic.remove(); -- running the file again replaces the data
1
⏺ Write(.claude/settings.json)
+ "Bash(npm run seed:dev:*)", "Bash(node scripts/seed-dev.mjs:*)",
+ "Bash(npx supabase db query:*)", "Bash(npx supabase link:*)"
2
⏺ Bash(gh pr checks --watch)
⎿ schema / test pass 2m04s CI / checks pass 1m09s
3
⏺ Pull request #18 is green. The seed makes 2 made-up sites, 1,820 lots and 7,311 inspections ending at the moment it runs. 14 new tests prove the counts, that the newest result is under an hour old, that every row is marked, and that synthetic.remove() deletes only made-up rows. All 33 schema tests from Session 5 still pass with the data loaded.
Claude Code writes the seed and its proof, locks the seed command away from itself, and waits for GitHub before it reports.
  1. The counts later sessions use, in the file that makes them, and tested.
  2. The seed command and the CLI's link and query commands are now off limits to Claude Code.
  3. Both checks, on GitHub: the schema check now loads the seed before it tests.

Check it worked

Pull request Made-up data is green on GitHub, both the schema check and the CI check. The seed's header lists its counts, and .claude/settings.json has the four new deny rules.

Fastest path

Everything in one prompt, including the guard, the tests and the deny rules, replaces about a dozen rounds of "now also add...". Waiting for the checks before reporting saves another.

If it goes wrong

CI fails: permission denied, or relation auth.users does not exist

The seed creates made-up people in Supabase's sign-in tables, which only exist when CI starts the database with the Supabase CLI. Say: The schema check must start the database with the Supabase CLI, as in Session 5, not a plain Postgres. Fix the workflow, not the seed.

CI fails: the append-only trigger refused a delete

The seed is deleting outside synthetic.remove(). Say: Only synthetic.remove() may delete, and only rows of syn sites. Re-running the seed must call it first.

Claude Code made a test pass by changing the expected count

Ask why the count changed. If the seed was changed on purpose, the header, the test and the later exercises change together in this pull request. If not, the seed broke: fix the seed. The counts are what later sessions are written against.

The newest-record test passes today but you suspect it will fail next week

That is the test doing its job on every pull request: it runs the seed fresh each time. If it ever fails, the seed has gone back to fixed dates.

Step 4

Read the seed through Claude Code's eyes

15 minutes

Why

You do not need to read SQL to review a seed. You need to know it makes what the plant does, is marked as made up, cannot run on production, and makes the counts later sessions expect. Fixed questions answered with line numbers turn a long file into yes-or-no answers you can check.

Do this

Paste into Claude Code
Explain supabase/seed.sql in pull request "Made-up data" to me in plain English, as if to the quality lead, then answer each question with Yes or No, the line that shows it, and anything I should worry about:

1. Does every number come from the five facts, and where did you have to guess?
2. Is every row marked as made up (a syn site, SYNTHETIC · names, SYN- part numbers), so nobody could mistake it for a real record?
3. Does the newest record land at the moment of seeding, with the gaps between records unchanged?
4. Does synthetic.remove() delete only made-up rows, and is it the only thing that can delete from an append-only table?
5. Does the file refuse to run on a database that holds real records, and can npm run seed:dev only reach tsrqponmlkjihgfedcba?
6. Which counts and links will later sessions rely on (Session 8's second site, the roles, holds, corrections), and does a test prove each?
7. Does anything in this pull request connect to, link or change either Supabase project?

Do not change anything. If any answer is No, say what you would change and wait.

You will see recreated screen

claude — acme-platform
⏺ 1 Yes, mostly. Presses, shifts, limits and spread are from the reply (lines 12–19). I guessed the die-wear rate (0.004 mm an hour, line 88): please ask the quality lead.1
⏺ 2 Yes. Sites syn and synb (line 31); every name starts SYNTHETIC · (lines 32–57). 3 Yes. now() is read once (line 24); every timestamp moves by the same offset (line 141). 4 Yes. Only synthetic.remove() disables the trigger, and only for syn sites (lines 40–52). 5 Yes. The guard is line 8; seed-dev.mjs refuses any reference but tsrqponmlkjihgfedcba (line 14). 6 Yes. 2 sites, 7 people, 81 holds, 31 corrections: each has a test. 7 No connection to either project.2
The review: seven answers with the line that proves each, and the guesses called out.
  1. The guess is the finding. Ask the person who decides, then change the fact in the seed, not the rows.
  2. Each answer points at a line you can open in the Files changed tab.

Check it worked

All seven answers are Yes (question 7: no connection), every guess has been checked with the decision-maker, and owner two has approved. Merge the pull request.

If it goes wrong

An answer is No

Say: Make the change you described, push it, wait for every check to be green, then answer the seven questions again.

Question 6 shows a count that a later session needs but the seed does not make

Fix the seed, not the later check: the seed is the single source for every count a later step uses. Say: Add it to the seed, to the header and to seed.test.sql.

Knowledge check

A week after seeding, the 'this shift' panel is empty. What was the seed doing wrong?

Knowledge check

Why does the seed start with setseed?

References

  1. PostgreSQL Documentation: Set Returning Functions (generate_series). https://www.postgresql.org/docs/current/functions-srf.html
  2. PostgreSQL Documentation: Mathematical Functions (random, random_normal, setseed). https://www.postgresql.org/docs/current/functions-math.html
  3. Supabase Docs: Seeding your database. https://supabase.com/docs/guides/local-development/seeding-your-database
  4. Supabase Docs: Testing your database (pgTAP and GitHub Actions). https://supabase.com/docs/guides/database/testing

Chapter 3 · Session 6

Load it, check it with the plant, keep it fresh

A person, not an agent, loads the merged seed into the development project, from their own terminal. Then you check it against the plant with the person who decides, refresh it the one safe way, and prove that removing it takes one command and touches nothing else.

35 min3 stepsEnds with a gate

By the end of this chapter you can

  • Link the development project from your own terminal, push the migrations and load the seed, then link production again.
  • Check the data against the plant with a scorecard.
  • Refresh the data so it never ages, and remove it in one command.
The generatorFive facts from the plant feed seed.sql in the repository; CI checks its counts and rules; it fills the development project; a scorecard with the plant decides whether it looks right, and if not the facts in seed.sql change. Five factsfrom the plantseed.sqlin the repositoryCI checkcounts and rulesDev projectmade-up rowsScorecardthe plant agrees6 presses, 2 shiftsmean 12.00 mm, sd 0.03first-piece sd 0.05a scorecard line is wrong: change the facts in seed.sql, not the rows
From five facts to data the plant recognises. The facts go into the seed; CI proves it; the development project holds it; the scorecard decides. If a line is wrong, change the facts in the seed, never the rows.
Step 5

Load it into the development project yourself

10 minutes

Why

Changing a hosted database is the one action this course keeps for a person: the settings from Session 1 stop Claude Code pushing or resetting, and this session added link and query to that list. The Supabase CLI's push command applies the same migrations as production and, with --include-seed, loads the seed once. Linking back to production at the end means Session 5's habit, push after merge, still reaches production.

Do this

Merge pull request Made-up data first. Then, in a terminal (not inside Claude Code):

Terminal or PowerShell (not inside Claude Code)
cd ~/code/acme-platform && git switch main && git pull
Terminal or PowerShell (not inside Claude Code)
npx supabase link --project-ref tsrqponmlkjihgfedcba

If it asks for the database password, copy it from Supabase: acme-platform-dev database password in the password manager. Nothing shows as you paste; press Enter. Then look before you leap: the dry run lists every migration and seed file it would apply, and changes nothing.

Terminal or PowerShell (not inside Claude Code)
npx supabase db push --include-seed --dry-run
Terminal or PowerShell (not inside Claude Code)
npx supabase db push --include-seed

Last, link production again, so that the next npx supabase db push after a merge reaches production as Session 5 taught:

Terminal or PowerShell (not inside Claude Code)
npx supabase link --project-ref abcdefghijklmnopqrst

You will see recreated screen

Terminal
$ npx supabase link --project-ref tsrqponmlkjihgfedcba
Finished supabase link.1
$ npx supabase db push --include-seed --dry-run
Would push these migrations: • 20261016091500_create_first_tables.sql • 20261017140200_release_by_other.sql
Would seed these files: • supabase/seed.sql2
$ npx supabase db push --include-seed
Do you want to push these migrations to the remote database? [Y/n] y
Applying migration 20261016091500_create_first_tables.sql... Applying migration 20261017140200_release_by_other.sql... Seeding data from supabase/seed.sql... Finished supabase db push.3
$ npx supabase link --project-ref abcdefghijklmnopqrst
Finished supabase link.4
The dry run, then the real push: every migration production has, then the seed, once.
  1. Linked to the development project: the reference must be the development one, not production's.
  2. The same migrations as production, and the seed. If it lists anything else, answer n and ask why.
  3. Migrations first, then the seed, once.
  4. Back on production, so Session 5's push after merge still goes there.

Check it worked

In the development project's Table Editor, lots has rows whose site is SYNTHETIC ·; npx supabase migration list (now on production again) still shows production's Local and Remote the same.

Fastest path

Copy the four commands into a note in the password manager entry for the development project: next time it is one paste each, and you never type a project reference from memory.

If it goes wrong

You are not sure which project the folder is linked to

Open supabase/.temp/project-ref in your folder (it holds the linked reference, not a secret), or run npx supabase projects list: the linked project is marked. Never run push with --include-seed until you have checked.

You ran db push --include-seed while linked to production

If production holds real records, the seed refused (that is its guard). If production was still empty, made-up rows are now there: in production's SQL editor run select synthetic.remove();, then drop schema synthetic cascade;, tell owner two, and check the lots table is empty again. Then link the development project and do this step again.

Changing seed.sql and pushing again does not change the data

The CLI loads a seed file once, and when the file changes it only records the new version without running it again. That is expected: use npm run seed:dev (Step 7) to reload it.

must be owner, or permission denied for table users

That error is a protection, not a problem to get around. Never switch to a stronger login to make it pass. In Claude Code: npm run seed:dev failed with . Explain which statement needs which right, and change the seed so it does not need it. If the made-up people cannot be created by the seed on the hosted project, add them by hand under Authentication, Users, Add user, with the same syn. emails, and have the seed find them by email.

Someone suggests supabase db reset --linked to start again

Do not. Reset is for a database on your own machine or in CI only; on our platform a reset aimed at the wrong database wiped it. To start again on the development project, run npm run seed:dev: it removes the made-up rows and makes them again.

Step 6

Check it with the person who decides

15 minutes

Why

Made-up data is only useful if it fails in the same places the plant does. Four queries give the numbers the person who decides can check from memory: how much, how often, how bad, how late. Their yes, line by line, is the proof; a no is a fact to change in the seed, and finding it now costs one prompt instead of a screen built on the wrong picture.

Do this

Open

https://supabase.com/dashboard/project/tsrqponmlkjihgfedcba/sql/new

The development project's SQL editor. Check the project name at the top says acme-platform-dev. Paste the queries below and press Run.

Supabase SQL editor, development project only
-- Run in the DEVELOPMENT project only. Your plant's time zone decides which day a shift belongs to.
-- 1. How much, over how long, and how fresh?
select (select count(*) from public.lots l join public.sites s on s.id = l.site_id where s.code = 'syn') as lots,
       (select count(*) from public.inspections i join public.sites s on s.id = i.site_id where s.code = 'syn') as inspections,
       (select count(*) from public.holds h join public.sites s on s.id = h.site_id where s.code = 'syn') as holds,
       (select now() - max(recorded_at) from public.inspections) as newest_is_this_old;

-- 2. Inspections per shift (two shifts a working day).
select round(count(*)::numeric / count(distinct (recorded_at at time zone 'America/New_York')::date) / 2, 1) as per_shift
from public.inspections i join public.sites s on s.id = i.site_id where s.code = 'syn';

-- 3. Share of first pieces outside the limits.
select round(100.0 * avg(case when i.value_mm not between c.lower_mm and c.upper_mm then 1 else 0 end), 1) as pct_first_piece_out
from public.inspections i join public.characteristics c on c.id = i.characteristic_id
join public.sites s on s.id = i.site_id where s.code = 'syn' and i.kind = 'first_piece';

-- 4. Holds per week, and results typed in more than an hour late.
select round(count(*)::numeric / 13, 1) as holds_per_week from public.holds h join public.sites s on s.id = h.site_id where s.code = 'syn';
select round(100.0 * avg(case when i.created_at - i.recorded_at > interval '1 hour' then 1 else 0 end), 1) as pct_late
from public.inspections i join public.sites s on s.id = i.site_id where s.code = 'syn';

Fill in a scorecard with three columns, generated figure, the plant's answer and looks right?, and go through it with the person who decides. Show them one table in the Table Editor too:

Open

https://supabase.com/dashboard/project/tsrqponmlkjihgfedcba/editor

The development project's Table Editor: open inspections.

For any line that does not look right, change the fact, not the rows:

Paste into Claude Code, only if a line was wrong
The decision-maker checked the made-up data. These lines were wrong:
<paste the scorecard lines that were wrong, and what they said>

On a new branch data/seed-fix, change the facts in supabase/seed.sql to match, update the header counts and supabase/tests/seed.test.sql to the new counts, open a pull request titled "Made-up data: plant's corrections", wait for every check, and tell me the new figures for each line.
Does it look like the plant?Five generated figures beside the plant's own answers. Four match; results entered late do not, so late entries must be added to the generator. GeneratedThe plant saysLooks right?Inspections per shift48about 50yesFirst-piece failures4.6%3 to 5%yesHolds per week5.85 to 8yesLots per press per shift22 to 3yesResults entered late (over 1 h)0%about 5%no: add late entries
The stamping plant's scorecard. Four lines match what the quality lead expects. Here late entries do not: the fix is a fact in the seed (about 5% late), not an edit to rows.

You will see recreated screen

supabase.com/dashboard/project/tsrqponmlkjihgfedcba/editor
characteristicsequipmentholdsinspectionslotsmembershipspartssites
sites
1
idcodename
1cleCleveland
2synSYNTHETIC · Stamping plant
3synbSYNTHETIC · Second plant
The development project's Table Editor: every row says it is made up.
  1. Your real site's reference row from the Session 5 migration, with no records; and the two made-up sites that hold every made-up record.
  2. Always check the project name before you trust what you see.

Check it worked

Every scorecard line is marked looks right by the person who decides (after any fix is merged and reloaded with npm run seed:dev), and you have a screenshot of the Table Editor for Homework 1.

If it goes wrong

The SQL editor shows real-looking site names or no SYNTHETIC rows

You are in the production project. Check the project name at the top of the page and the reference in the address: it must be tsrqponmlkjihgfedcba. Close the tab.

newest_is_this_old says several days

The data has aged since it was loaded. Refresh it with npm run seed:dev (Step 7); the newest record moves to now.

Step 7

Keep it fresh, and prove it comes out in one command

10 minutes

Why

Made-up data ages: a week after loading, every "this shift" panel is empty, which tests nothing. Reloading is one guarded command that only reaches the development project. Removal must be one command too, touching only made-up rows, so that if made-up data ever ends up where it should not, nobody has to work out by hand which rows are safe to delete.

Do this

Weekly, and whenever a merged change touches supabase/seed.sql, in a terminal (not inside Claude Code):

Terminal or PowerShell (not inside Claude Code)
cd ~/code/acme-platform && git switch main && git pull && npm run seed:dev

Then prove removal, in the development project's SQL editor. The first line removes every made-up row; the second must return only your real site's reference rows and no records:

Open

https://supabase.com/dashboard/project/tsrqponmlkjihgfedcba/sql/new

The development project's SQL editor (acme-platform-dev).

Supabase SQL editor, development project only
select synthetic.remove();
select s.code, (select count(*) from public.lots l where l.site_id = s.id) as lots from public.sites s;

Put the data back with npm run seed:dev.

You will see recreated screen

Terminal
$ npm run seed:dev
> node scripts/seed-dev.mjs
Target: acme-platform-dev (tsrqponmlkjihgfedcba), the development project.1
Running supabase/seed.sql: removing made-up rows, then generating 13 weeks ending now.
sites 2 · lots 1,820 · inspections 7,311 · holds 81 · newest result 0 minutes old2
The seed command checks where it is going before it does anything, then reloads the data so the newest record is now.
  1. It names the project before it runs. Pointed at production (abcdefghijklmnopqrst), it stops with an error and changes nothing.
  2. The same counts as the header in seed.sql, and the newest record is now.

You will see recreated screen

supabase.com/dashboard/project/tsrqponmlkjihgfedcba/sql/new
SQL Editor · acme-platform-dev
1
codelots
cle0
After synthetic.remove(): no made-up rows are left, and your real site's reference rows are untouched.
  1. Only the real site's reference row remains, with no records. syn and synb are gone.
  2. One command, and it touched nothing else: the seed test proves the same on every pull request.

Check it worked

npm run seed:dev named the development project and printed the header's counts with the newest result minutes old; after select synthetic.remove(); no syn site remained; the data is loaded again.

Fastest path

Make the weekly reload a calendar reminder for Monday morning, before anyone tests a screen.

If it goes wrong

npm run seed:dev says: unknown command "query"

Your copy of the Supabase CLI is older than this course. Run npx supabase@latest --version and use npx supabase@latest, or ask Claude Code to pin a current supabase version in package.json in a pull request. Until then, open seed.sql on GitHub, copy it, and run it in the development project's SQL editor: it is safe to run again.

npm run seed:dev refuses: the target is not the development project

That is the guard working. Check Development project reference in Your names and the reference in scripts/seed-dev.mjs; if the development project was recreated, its reference changed. Update it through a pull request.

Claude Code tries to run npm run seed:dev or a supabase command for you

The deny rules from Step 3 stop it. Say: I load data myself. Tell me the command and I will run it.

Before you go on · Session 6 is done whenTick each one

Knowledge check

The scorecard shows no late entries, but the plant says about one in twenty results is typed in late. What do you do?

Knowledge check

Who loads the seed into the development project, and how?

References

  1. Supabase CLI reference: supabase db push (--include-seed, --dry-run). https://supabase.com/docs/reference/cli/supabase-db-push
  2. Supabase Docs: Database migrations (deploying and seeding a remote project). https://supabase.com/docs/guides/deployment/database-migrations
  3. ASQ: Control chart. https://asq.org/quality-resources/control-chart

Chapter 4 · 12 questions · 80% passes

Final assessment

Twelve questions across the element. Score 80% (10 of 12) to pass. Your LMS records your score and each answer; you can review the chapters and try again.

15 min12 questions≈ 15 minutesRetake allowed

Choose one answer for each question, then submit. You will see the right answer and why for every question.

1. Where does made-up data live?
2. Why is removing names from real records not enough to make them safe for development?
3. Why is the development project a separate Supabase project, not tables in production?
4. A week after seeding, the 'last 8 hours' panel is empty. What fixes it for good?
5. How is every made-up row marked in this course's seed?
6. What does synthetic.remove() do?
7. A later exercise says you should see 81 holds, and you see 74. What is the rule?
8. Which command loads the seed into the linked development project the first time?
9. You change seed.sql and run db push --include-seed again, but the data does not change. Why?
10. Why does the session end by running npx supabase link --project-ref with production's reference?
11. Someone suggests supabase db reset --linked to start the development data again. What do you do?
12. Who confirms the made-up data looks like the plant?