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
+18 -1
View File
@@ -67,6 +67,8 @@ ipalEnvRules({
serverUrlVar?: string, // default 'NEXT_PUBLIC_SERVER_URL'
secretVar?: string, // default 'PAYLOAD_SECRET'
databaseVar?: string, // default 'DATABASE_URI'
databaseName?: boolean | { domain?: string; warn?: (message: string) => void },
// WARN (never fail) when the DATABASE_URI database is not <domain without dots>_prod / _dev
})
```
@@ -101,6 +103,21 @@ assertEnv([
])
```
### Database names — `databaseName`
The naming rule (deployment.md §4.2a): the site's domain with the dots removed, plus `_prod` / `_dev` —
`intecion.com` → `intecioncom_prod` / `intecioncom_dev`. `ipalEnvRules({ databaseName: true })` adds a check that
only **warns** (console, or your `warn`) when the database in `DATABASE_URI` breaks it. The domain comes from
`NEXT_PUBLIC_SERVER_URL` in `process.env` (localhost and dotless hosts are skipped) or from `{ domain }`.
```ts
import { checkDatabaseName, databaseNameFromUri, databaseNamesFor } from '@intecion/ipal-kit/env'
databaseNamesFor('https://www.intecion.com') // { prod: 'intecioncom_prod', dev: 'intecioncom_dev' }
databaseNameFromUri('postgres://u:p@db:5432/intecioncom_prod') // 'intecioncom_prod' (null for file:/no name)
checkDatabaseName({ databaseUri: process.env.DATABASE_URI, domain: 'intecion.com' }) // warning text or null
```
## assertEnv — the validator
```ts
@@ -151,7 +168,7 @@ redeploys.
## Exports
```ts
import { assertEnv, ipalEnvRules } from '@intecion/ipal-kit/env'
import { assertEnv, checkDatabaseName, databaseNameFromUri, databaseNamesFor, ipalEnvRules } from '@intecion/ipal-kit/env'
import type { EnvRule, EnvKind, AssertEnvOptions, IpalEnvFeatures } from '@intecion/ipal-kit/env'
```