Skip to content

ai-unified-process/aiup-drizzle

v3.1.1

AI Unified Process migration and persistence layers - Drizzle ORM schema, generated PostgreSQL migrations, repositories, and their tests

drizzle-persistence

Builds the persistence layer of a use case (UC-XXX) with Drizzle ORM in a NestJS API: one @Injectable repository per aggregate with the injected Drizzle database, every query of the feature in that file, explicit projections, joins or relational queries instead of a query per row, paging and dynamic filters, optimistic locking when the entity has a version, and UC-XXX BR-YYY markers on the query conditions that enforce a business rule. Drizzle has no ambient transaction, so the repository owns db.transaction and hands an optional tx parameter to writes that span repositories. Hands the repository method signatures and row types to the service layer. Normally run by /use-case-implement after the migration layer; can be run directly. Use when the user asks to "write the Drizzle repository", "implement the data access for UC-001", "add a Drizzle query", "write the data access layer", or mentions Drizzle queries, db.transaction, *.repository.ts, or a repository in a project that combines layer plugins.

drizzle-persistence-test

Writes the persistence layer tests of a use case (UC-XXX) for Drizzle repositories: Vitest integration tests against a real PostgreSQL in Testcontainers, test data from the use case's seed file, expected values from the specification and the test data, one describe('UC-XXX: …') per use case and one it per query behaviour. Tests only queries with logic of their own — filters, joins, projections, paging, optimistic locking, transactions that must roll back — not what the integration layer's tests already cover. /use-case-test runs it only to reconcile existing tests, for queries the integration layer cannot reach, or when the persistence layer is named; can be run directly. Use when the user asks to "test the Drizzle repository", "write repository tests for UC-001", "test this query against the database", or mentions Drizzle repository tests or Testcontainers tests of the data access in a project that combines layer plugins.

drizzle-schema

Builds the migration layer of a use case (UC-XXX) with Drizzle over PostgreSQL: edits the pg-core schema file that drizzle.config.ts names and generates the SQL migration with drizzle-kit, never by hand: a complete table, with every attribute and constraint of the entity model, for each entity the use case needs that has no table yet, and a change only where an existing table lags behind the entity model. Marks a CHECK or unique index that enforces a business rule with // UC-XXX BR-YYY in the schema file. Normally run by /use-case-implement as the first layer; can be run directly, with a use case or for the whole entity model. Use when the user asks to "create a migration", "generate SQL", "update the schema", "add a column", "create the tables for UC-001", or mentions Drizzle, drizzle-kit, pg-core, schema.ts, or database versioning in a project that combines layer plugins. Test data belongs to the test skills.