import { IMPOSSIBLE, VersionInfo } from '@start9labs/start-sdk'

/**
 * v1.1.0:1 — Programs (manual create / save / follow).
 *
 * The Program / ProgramWeek / ProgramDay / ProgramExercise schema
 * has existed since the legacy `workout-log` package but had no
 * UI to use it. This release ships:
 *
 *   - /main/programs (list) with a today's-session card if any
 *     program is active.
 *   - /main/programs/new (create form) with the full nested
 *     editor: program metadata -> weeks -> days -> exercises.
 *   - /main/programs/[id] (detail + edit) using the same editor,
 *     plus today's-session callout + "Start this session"
 *     button when applicable.
 *   - API: GET/POST /api/programs, GET/PATCH/DELETE
 *     /api/programs/[id]. PATCH replaces the entire weeks tree
 *     in one transaction (same shape POST accepts) — keeps the
 *     UI editor and the upcoming AI apply flow on the same code
 *     path.
 *   - "Start this session" wires through
 *     POST /api/programs/[id]/days/[dayId]/start which creates a
 *     Workout pre-populated with empty SetLogs from the planned
 *     ProgramExercises (one row per planned set), tagged with
 *     Workout.programDayId so we can later compute adherence.
 *
 * Schema change
 *   - Workout.programDayId (nullable FK to ProgramDay) added.
 *   - Compat ALTER in docker_entrypoint.sh adds the column +
 *     index to existing /data on first boot. ON DELETE SET NULL
 *     so deleting a program doesn't catastrophically remove
 *     historical workouts logged against it.
 *
 * This release is the foundation for v1.1.0:2's AI-generated
 * programs — the AI will produce the same JSON shape that POST
 * /api/programs already accepts.
 *
 * No data migration. /data on existing installs is untouched
 * apart from the new column.
 */
export const v_1_1_0_1 = VersionInfo.of({
  version: '1.1.0:1',
  releaseNotes: {
    en_US:
      'Programs UI shipped. Build a multi-week training plan, mark it active, and follow it day by day from a new "Today\'s session" card. Includes a full nested editor (program -> weeks -> days -> exercises), starts a session as a pre-populated workout you fill in as you go, and tracks Workout.programDayId for upcoming adherence analytics. Foundation for v1.1.0:2 (AI-generated programs).',
  },
  migrations: {
    up: async () => {},
    down: IMPOSSIBLE,
  },
})
