work-hub-server/openspec/changes/archive/2026-06-04-add-shared-schema-package/specs/database-schema/spec.md
Nicolas HOARAU 9190908062 docs: archive completed changes
Archive add-shared-schema-package and swap-superstruct-valibot changes to openspec/changes/archive/
2026-06-04 12:49:12 +04:00

1.7 KiB

ADDED Requirements

Requirement: Define PostgreSQL tables with Drizzle ORM

The package SHALL export Drizzle ORM table definitions using pgTable from drizzle-orm/pg-core, with proper column types, constraints, and defaults targeting PostgreSQL.

Scenario: Table exports are available

  • WHEN another package imports from @workspace/schema
  • THEN all Drizzle table definitions SHALL be accessible as named exports

Scenario: Table uses standard column types

  • WHEN a column is defined in a Drizzle table
  • THEN it SHALL use a drizzle-orm/pg-core column type (e.g., text(), integer(), timestamp(), uuid(), boolean())

Requirement: Define PostgreSQL enums

The package SHALL support PostgreSQL enum definitions using pgEnum from drizzle-orm/pg-core for constrained string fields.

Scenario: Enum is defined and exportable

  • WHEN an enum is created with pgEnum
  • THEN it SHALL be exportable and usable as a column type in table definitions

Requirement: Define table relations

The package SHALL define Drizzle relations (relations from drizzle-orm) between tables, supporting one-to-many, many-to-one, and many-to-many relationships.

  • WHEN a relation is defined between two tables
  • THEN the related fields SHALL be queryable via Drizzle's relational query API

Requirement: All schemas are co-located

The package SHALL colocate Drizzle table definitions, enums, and relations within the same directory structure under src/drizzle/.

Scenario: Single import for database concerns

  • WHEN a consumer needs database schema
  • THEN it SHALL import from @workspace/schema without accessing internal paths