@cfxlabsinc/b2b-services
    Preparing search index...

    Module @cfxlabsinc/nx-db

    @cfxlabsinc/nx-db

    Infers three targets on every project with src/schema/*.ts (one file per table), and on packages/db while its tables still live under src/drizzle/schema/:

    • db-generate: bun tools/db/generate.ts --project-root <root>, after the db-generate of every dependency. Takes --name <n> and --baseline.
    • db-check: drizzle-kit check with the shared config.
    • db-migrate-new: dbmate -d <root>/db/migrations new <name> (<root>/migrations for packages/db).

    src/schema/ is reserved for Drizzle tables: any src/schema/*.ts makes a package a database owner.

    The shared config is tools/db/drizzle.config.ts. It reads DB_PROJECT_ROOT and the optional DB_SCHEMA_GLOB, DB_OUT_DIR overrides.

    generate diffs the schema against the committed snapshots only, never a database. Drizzle writes <root>/db/migrations/<14-digit-version>_<name>/ with snapshot.json; the wrapper turns its migration.sql into the dbmate file <version>_<name>.sql beside it and deletes the original. --baseline keeps the snapshot and writes no SQL.

    Each CREATE TABLE|VIEW|MATERIALIZED VIEW gets an ALTER … OWNER TO cfx_owner, guarded by a pg_roles check because migrations run as cfx_ci (see rules/database.md § Migrations). The -- migrate:down section is empty.

    drizzle-kit generate ignores casing in the config. A schema must build its tables from snakeCase.schema("<pg-schema>") (see packages/db/src/drizzle/schema/b2b.ts); a plain pgSchema("b2b") silently yields camelCase columns.

    A config's schema glob decides which tables enter its snapshot. A reference to a table in another package produces only the FOREIGN KEY statement; the referenced table is not recreated. dependsOn: ["^db-generate"] orders the owners.

    createNodesV2