Database naming rule; seeding after launch touches named records only

- Rule (VERY IMPORTANT): databases are named <domain without dots>_prod /
  _dev (intecion.com → intecioncom_prod / intecioncom_dev) on MongoDB and
  Postgres — AGENT.md top rules, deployment.md §4.2a (Coolify), env.md,
  ipal-setup architecture questions (derive, then confirm), AGENTS.md
  template. ipalEnvRules({ databaseName }) warns (never fails) on a
  mismatch, domain from NEXT_PUBLIC_SERVER_URL or { domain }, { warn }
  overridable; helpers databaseNamesFor, databaseNameFromUri,
  checkDatabaseName from the root and /env.
- Rule (VERY IMPORTANT): after launch never re-seed everything — AGENT.md,
  seeding.md, ipal-site, ipal-form, ipal-reference. createSeeder gains
  `only` / SEED_ONLY (pages:slug, forms:title, global:slug, collection:*;
  the rest → "skip (not listed)") and refuses a run with no record list
  against a production / non-local database unless IPAL_SEED_ALLOW_FULL=1
  (guard.allowFull; dry runs allowed). Seed templates carry an ONLY list;
  the form seed touches only its own form.
- Tests: seed only/full-run guard, database-name helpers and warning.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-10-29 13:27:46 +01:00
co-authored by Claude Opus 5.5
parent 9ecab39783
commit af7d96f0e3
19 changed files with 331 additions and 46 deletions
+24 -2
View File
@@ -19,8 +19,9 @@ Related: [PROGRAMISTA.md](./dev/PROGRAMISTA.md) (from zero to a working site, §
### Core (REQUIRED — the project will not start without them)
```bash
# Database (Mongo or Postgres — depending on the project)
DATABASE_URI=mongodb://... # or postgres://... / file:./dev.db (dev)
# Database (Mongo or Postgres — depending on the project); name = <domain without dots>_prod / _dev (§4.2a)
DATABASE_URI=mongodb://user:pass@mongo:27017/intecioncom_prod?authSource=admin # or postgres://user:pass@db:5432/intecioncom_prod
# dev: …/intecioncom_dev, or file:./dev.db
# Payload secret (signs sessions/tokens) — random, long
PAYLOAD_SECRET=<random-string-min-32-chars>
@@ -244,6 +245,27 @@ One Coolify **application** per project (built from the Git repo) plus a Coolify
- **Redirect** www ↔ apex in the app's domain/redirect setting (Direction) so the canonical host is the one in
`NEXT_PUBLIC_SERVER_URL` — canonical, hreflang and sitemap URLs use that variable, the redirect must agree with it.
### 4.2a Database names (VERY IMPORTANT)
Every project uses the same names, on MongoDB and Postgres: the site's domain **with the dots removed**, plus
`_prod` (production) or `_dev` (development / staging). No other suffixes, no `payload`, `test` or `db1`.
| Site | Production | Development |
|---|---|---|
| `intecion.com` | `intecioncom_prod` | `intecioncom_dev` |
| `architektimprez.pl` | `architektimprezpl_prod` | `architektimprezpl_dev` |
- The name is the path of `DATABASE_URI`: `mongodb://user:pass@mongo:27017/intecioncom_prod?authSource=admin`,
`postgres://user:pass@db:5432/intecioncom_prod` (the Postgres database name, not the user or the schema).
- In Coolify: create the database resource with that database name (Postgres "Initial database", or the name in the
Mongo connection string), and set `DATABASE_URI` on the app to it.
- A leading `www.` is not part of the name; a hyphen in the domain stays (quote the name in SQL:
`CREATE DATABASE "my-sitepl_prod"`).
- **Check:** `ipalEnvRules({ databaseName: true })` warns at startup (never fails) when the name in `DATABASE_URI`
does not match the domain in `NEXT_PUBLIC_SERVER_URL` (skipped for localhost). `{ domain: 'intecion.com' }` sets the
domain, `{ warn }` replaces the console warning; leave the option out to turn the check off. Helpers:
`databaseNamesFor`, `databaseNameFromUri`, `checkDatabaseName` from `@intecion/ipal-kit/env` (env.md).
### 4.2 Environment variables — where and when
Coolify → the application → **Environment Variables**. Each variable can be available at **build time**,