Skip to content

refactor: align persistence layer with UUID identifiers and Drizzle schema typing#13

Merged
heitorrsdev merged 3 commits intomainfrom
refactor/mappers-use-drizzle-insert-types
Feb 27, 2026
Merged

refactor: align persistence layer with UUID identifiers and Drizzle schema typing#13
heitorrsdev merged 3 commits intomainfrom
refactor/mappers-use-drizzle-insert-types

Conversation

@heitorrsdev
Copy link
Owner

Description

This PR consolidates three structural improvements: stabilization of the test database container, standardization of all primary and foreign keys as UUID, and removal of manual row typings in favor of Drizzle-inferred types.

The changes improve architectural consistency, reduce schema duplication, and strengthen alignment between database and application layers.


What was done

  • Stabilized test database environment:

    • Added healthcheck to the Postgres test container
    • Disabled restart policy to prevent flaky behavior
    • Removed temporary debug log from concurrency test
  • Standardized identifier strategy:

    • Migrated primary and foreign key columns from TEXT to UUID
    • Recreated affected constraints and exclusion rules
    • Added ADR documenting the UUID decision and its implications
  • Reduced type duplication and coupling:

    • Replaced manual row interfaces with .$inferSelect / .$inferInsert
    • Removed explicit row typing in reservation repository
    • Aligned mappers and tests with schema-derived types

Why

  • The test container configuration could lead to unstable or misleading test runs
  • Identifiers were semantically UUID but structurally defined as TEXT, creating inconsistency
  • Manual row types duplicated schema definitions and increased maintenance cost
  • Schema-derived typing strengthens architectural boundaries and reduces drift between layers

Notes

  • No business behavior was modified
  • Database schema change is safe (no persisted data exists)
  • All changes are covered by existing integration tests
  • The UUID decision is formally documented under docs/adr

chore: remove temporary debug log from concurrency test

chore: disable restart policy for postgres test container

chore: add healthcheck to test database container
docs: add ADR for UUID primary key strategy
@heitorrsdev heitorrsdev force-pushed the refactor/mappers-use-drizzle-insert-types branch 2 times, most recently from 2d08872 to e369669 Compare February 27, 2026 21:23
…pers and tests

refactor: remove explicit row typing in reservation repository

fix: make input optional in test factories

fix: make createdAt mandatory in reservation and barber schema
@heitorrsdev heitorrsdev force-pushed the refactor/mappers-use-drizzle-insert-types branch from e369669 to c0edcfe Compare February 27, 2026 21:23
@heitorrsdev heitorrsdev merged commit 9718c72 into main Feb 27, 2026
1 check passed
@heitorrsdev heitorrsdev deleted the refactor/mappers-use-drizzle-insert-types branch February 27, 2026 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant