Skip to content

Add routine schedules table - #61

Merged
rd-code-23 merged 1 commit into
mainfrom
feature/routine-schedules-schema
Aug 24, 2026
Merged

rd-code-23 merged 1 commit into
mainfrom
feature/routine-schedules-schema

Conversation

@rd-code-23

Copy link
Copy Markdown
Owner

Problem

Routines may optionally be planned for recurring days and local times, but the persistence model did not yet have a schedule record. Scheduling must represent user intent without prematurely introducing time-zone conversion, notifications, or calendar infrastructure.

What changed

  • Added the Drizzle routine_schedules table.
  • Exported it from the complete database schema index.
  • Generated migration 0005_freezing_siren.sql and its Drizzle metadata.
  • Finalized and documented the day-of-week convention in docs/database.md.
  • Added concise field comments and explicit routine-deletion behavior.

Table design

Each schedule record contains:

  • generated UUID identifier
  • required parent routine
  • day of week
  • user-local planned time
  • created and updated timestamps

The day convention is Sunday 0 through Saturday 6, matching JavaScript's Date#getDay() convention. PostgreSQL enforces the allowed 0–6 range.

local_time uses TIME(0) without a time-zone offset because it represents recurring local intent, such as Monday at 6:00 PM, rather than an absolute moment. Time-zone storage and notification conversion remain intentionally out of scope.

Integrity and deletion behavior

A unique (routine_id, day_of_week, local_time) index rejects duplicate schedule entries and supports loading schedules by routine through its leading routine column.

Deleting a routine cascades to its schedule entries because those entries have no meaning without their parent routine.

Scope

This PR implements only #60. It does not add notifications, user time zones, one-off calendar dates, schedule endpoints, routine UI, or dashboard integration.

Migration verification

Drizzle detected six tables and the expected schedule shape: six columns, one index, and one foreign key. A second generation reported No schema changes, nothing to migrate.

Verification

  • pnpm --filter @goforlift/api typecheck
  • pnpm --filter @goforlift/api test — 48 tests passed
  • pnpm --filter @goforlift/api lint
  • Prettier checks for changed schema, metadata, and documentation
  • git diff --check

The migration is committed but was not applied to a developer's local PostgreSQL database as part of this PR.

Closes #60

@rd-code-23
rd-code-23 merged commit ee1d05c into main Aug 24, 2026
1 check passed
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.

[Routines][Phase 1] Implement routine schedules table

1 participant