# Local database seed Anything in `nearledb/` or `cataloguedb/` is applied by Postgres, in filename order, **the first time the volume is created**. Editing a file later does nothing on its own — drop the volume to re-apply: ``` docker compose -f ../docker-compose.local.yml down -v ``` ## Why this is not optional Fiesta runs migrations on boot, and most of them assume tables that nothing in this repository creates: ``` ALTER TABLE products ADD COLUMN IF NOT EXISTS productimages ALTER TABLE products ADD COLUMN IF NOT EXISTS imageid ALTER TABLE productlocations ADD COLUMN IF NOT EXISTS publishedat ``` `AutoMigrate` covers only `stockrequests`, the two POS order tables and `staffshifts`. Against an empty database the first `ALTER` fails and `log.Fatal` stops the process — so a schema is required before the first run. ## Getting the schema Structure only, no data, no ownership: ``` pg_dump --schema-only --no-owner --no-privileges \ -h -p 5433 -U -d nearledb \ > nearledb/01-schema.sql ``` **Take the schema, not the data.** A dump with rows in it puts real customers, real orders and real (cleartext) passwords on a laptop, and this directory is inside a git repository. `.gitignore` excludes `*.sql` here for that reason. ## Getting something to test against `nearledb/02-seed.sql` is committed and applied automatically, so a fresh volume already has a merchant to sign into. It invents one rather than copying one, which is why it can live here at all. | Account | Password | Opens | |---|---|---| | `super@nearle.invalid` | `localdev` | Nearle Admin — the platform workspace | | `admin@testmart.invalid` | `localdev` | Store Admin — all of Testmart's branches | | `main@testmart.invalid` | `localdev` | Store user — Testmart Main only | It also seeds the role ladder, three aisles under category 2, and a second merchant (`Halfmart`) deliberately left in the broken `categoryid = 0` shape as a permanent regression fixture. The sequences are moved past the seeded ids at the end, so the first row you create locally does not come back as id 1. If you need something it does not cover: - **Onboard a tenant through the console.** That exercises the real path and is usually what you want. - **Copy a few rows** you actually need with `pg_dump --data-only --table=...`. Check what you are copying: `app_users.password` is stored in clear. ## The catalogue database `cataloguedb/02-seed.sql` is committed too, and also entirely invented. The real catalogue is another team's scrape of real retailers and a dump of it does not belong on a laptop. Without it the catalogue database exists but holds no catalogue: every `brand_*` table is missing, `getbrands` answers 500, and the global catalogue screen, the import flow and `importcatalogueproduct` cannot be exercised at all. The seed gives you two brands: - `brand_testbrand` — every column the reader knows about, four products, one of them deliberately with no images. - `brand_sparsebrand` — only `id`, `product_name` and a price, to keep the degraded-but-still-listed path covered. Brands are discovered by table name, so adding another is just another `brand_*` table.