Skip to content

Add schema v2 with stable IDs and migration - #14

Merged
polymorcodeus merged 2 commits into
mainfrom
v2
Aug 23, 2026
Merged

Add schema v2 with stable IDs and migration#14
polymorcodeus merged 2 commits into
mainfrom
v2

Conversation

@polymorcodeus

@polymorcodeus polymorcodeus commented Aug 23, 2026

Copy link
Copy Markdown
Owner

Here's the same work rewritten to match the lnk #23 voice (imperative title, ## Summary opener, bold-lead-in bullets, a command table, guardrails section, make check closer):

Summary

Adds schema v2: stable IDs and created_at/updated_at on every entity (Shelf, Collection, Mark), plus an explicit book migrate command to upgrade existing v1 shelf files in place. Completes the schema-v2 spine ahead of the SQLite index work and the v2.0.0 release.

What's new

  • Stable IDs - shelves and collections get deterministic-seed IDs (marks already ship catalog_id), decoupling identity from the human-readable name so renames stop being destructive.
  • Timestamps - created_at/updated_at on all entities, plus deleted_at on Mark (schema only; soft-delete behavior lands separately).
  • book migrate - non-interactive v1-to-v2 upgrade, gated behind --confirm like other writes.

Usage

Command Purpose
book migrate upgrade all v1 shelf files in shelf.d/ to v2 schema

Behavior changes / guardrails

  • Migrated rows get empty timestamps, so two machines migrating the same v1 file produce byte-identical output; only entities created after v2 carry real timestamps.
  • book migrate is idempotent: re-running on v2 files is a no-op and reports "N upgraded, M already v2".
  • Git-first rollback: inside a git repo, migration requires a clean tree and writes no backups; outside git, it keeps a one-time .bak per file.
  • IDs are seeds only: once assigned they are stored and never recomputed, so a later rename keeps identity.

Testing

  • Golden v1-to-v2 fixture migration, idempotency (second run no-op), git-clean/dirty, and .bak fallback coverage.
  • Migrated files pass round-trip idempotency.
  • make check runs fmt, vet, lint, and tests; all green.

@polymorcodeus polymorcodeus self-assigned this Aug 23, 2026
@polymorcodeus polymorcodeus changed the title V2 Schema Change Add schema v2 with stable IDs and migration Aug 23, 2026
@polymorcodeus
polymorcodeus merged commit e93b936 into main Aug 23, 2026
4 checks passed
@polymorcodeus
polymorcodeus deleted the v2 branch August 23, 2026 19:34
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