Commit e44fbbb059

e44fbbb059bdb4d8d41469777a1e4b65ed2eb9af

parent: c367b78f17

Verified · cmc ci/build: success ci/test: success

cmc <hello@cleberg.net> · 2026-09-12 01:47 UTC

store: snippets are migration 0054

main took 0053 for the notification watch setting while this branch was open.

Ref #195
CHANGELOG.org +1 −1
@@ -9,7 +9,7 @@ anything beyond "replace the binary and restart" is needed.
99Snippets (#195): named text files a user owns outside any repository,
1010shared by URL and edited in place.
1111
12- Migration 0053: =snippets= and =snippet_files=.
12- Migration 0054: =snippets= and =snippet_files=.
1313- =snippet create|show|list|edit|delete= and =snippet file
1414 set|get|remove=. Files are UTF-8 under =limits.max_snippet_bytes=
1515 (1MB), at most 64 per snippet; a snippet keeps at least one.
docs/plans/2026-09-11-snippets.md +10 −10
@@ -4,7 +4,7 @@
44
55**Goal:** A snippet a user owns, shares by URL, and edits in place: one or more named text files, a description, and a visibility. Closes #195.
66
7**Architecture:** Two new tables (migration 0053) hold snippets and their files; content sits in SQLite as a BLOB. Eight `snippet` control commands in `internal/control/snippet.go` are the only write path; the CLI, the JSON API and the web forms dispatch into them. Read rules live in `internal/policy/snippets.go`. The web renders under `/{owner}/-/snippets`, the pattern `/{owner}/-/labels` set.
7**Architecture:** Two new tables (migration 0054) hold snippets and their files; content sits in SQLite as a BLOB. Eight `snippet` control commands in `internal/control/snippet.go` are the only write path; the CLI, the JSON API and the web forms dispatch into them. Read rules live in `internal/policy/snippets.go`. The web renders under `/{owner}/-/snippets`, the pattern `/{owner}/-/labels` set.
88
99**Tech Stack:** Go, SQLite via modernc (hand-written SQL, no ORM), Go `html/template`, chroma through the existing `highlight`, the control registry in `internal/control`, the e2e harness in `e2e/`.
1010
@@ -33,11 +33,11 @@ Names used across tasks, fixed here so the tasks agree:
3333
3434---
3535
36### Task 1: Migration 0053 and the store
36### Task 1: Migration 0054 and the store
3737
3838**Files:**
39- Create: `internal/store/migrations/0053_snippets.up.sql`
40- Create: `internal/store/migrations/0053_snippets.down.sql`
39- Create: `internal/store/migrations/0054_snippets.up.sql`
40- Create: `internal/store/migrations/0054_snippets.down.sql`
4141- Create: `internal/store/snippets.go`
4242- Test: `internal/store/snippets_test.go`
4343
@@ -193,7 +193,7 @@ Expected: compile error, `s.CreateSnippet undefined`.
193193
194194- [ ] **Step 3: Write the migration**
195195
196`internal/store/migrations/0053_snippets.up.sql`:
196`internal/store/migrations/0054_snippets.up.sql`:
197197
198198```sql
199199-- Snippets: named text files a user owns and shares by URL, outside any
@@ -218,7 +218,7 @@ CREATE TABLE snippet_files (
218218);
219219```
220220
221`internal/store/migrations/0053_snippets.down.sql`:
221`internal/store/migrations/0054_snippets.down.sql`:
222222
223223```sql
224224DROP TABLE snippet_files;
@@ -463,8 +463,8 @@ Expected: PASS, including `TestMigrateUpDown` (the down file drops both tables)
463463- [ ] **Step 6: Commit**
464464
465465```bash
466git add internal/store/migrations/0053_snippets.up.sql internal/store/migrations/0053_snippets.down.sql internal/store/snippets.go internal/store/snippets_test.go
467git commit -m "store: snippets and snippet_files (migration 0053)
466git add internal/store/migrations/0054_snippets.up.sql internal/store/migrations/0054_snippets.down.sql internal/store/snippets.go internal/store/snippets_test.go
467git commit -m "store: snippets and snippet_files (migration 0054)
468468
469469Ref #195"
470470```
@@ -1857,7 +1857,7 @@ Before `* v1.19.0 — 2026-09-11` add:
18571857Snippets (#195): named text files a user owns outside any repository,
18581858shared by URL and edited in place.
18591859
1860- Migration 0053: =snippets= and =snippet_files=.
1860- Migration 0054: =snippets= and =snippet_files=.
18611861- =snippet create|show|list|edit|delete= and =snippet file
18621862 set|get|remove=. Files are UTF-8 under =limits.max_snippet_bytes=
18631863 (1MB), at most 64 per snippet; a snippet keeps at least one.
@@ -1890,7 +1890,7 @@ gitbay mr create --source snippets --target main --title "Snippets (#195)" --fil
18901890Named text files a user owns outside any repository, shared by URL and
18911891edited in place. Spec: docs/specs/2026-09-11-snippets-design.md.
18921892
1893Migration 0053. Commands snippet create|show|list|edit|delete and
1893Migration 0054. Commands snippet create|show|list|edit|delete and
18941894snippet file set|get|remove; web under /{owner}/-/snippets with forms
18951895dispatching the same commands. New limit max_snippet_bytes (1MB).
18961896
docs/specs/2026-09-11-snippets-design.md +1 −1
@@ -57,7 +57,7 @@ Decisions taken on the way, with the alternatives rejected:
5757
5858## Data
5959
60Migration 0053, no rebuild:
60Migration 0054, no rebuild:
6161
6262```sql
6363CREATE TABLE snippets (
internal/store/migrations/0053_snippets.down.sql → internal/store/migrations/0054_snippets.down.sql renamed
internal/store/migrations/0053_snippets.up.sql → internal/store/migrations/0054_snippets.up.sql renamed