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

Layout: unified · split

CHANGELOG.org +1 −1
@@ -9,7 +9,7 @@ anything beyond "replace the binary and restart" is needed.
9Snippets (#195): named text files a user owns outside any repository, 9Snippets (#195): named text files a user owns outside any repository,
10shared by URL and edited in place. 10shared by URL and edited in place.
11 11
12- Migration 0053: =snippets= and =snippet_files=. 12- Migration 0054: =snippets= and =snippet_files=.
13- =snippet create|show|list|edit|delete= and =snippet file 13- =snippet create|show|list|edit|delete= and =snippet file
14 set|get|remove=. Files are UTF-8 under =limits.max_snippet_bytes= 14 set|get|remove=. Files are UTF-8 under =limits.max_snippet_bytes=
15 (1MB), at most 64 per snippet; a snippet keeps at least one. 15 (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 @@
4 4
5**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. 5**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.
6 6
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.
8 8
9**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/`. 9**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/`.
10 10
@@ -33,11 +33,11 @@ Names used across tasks, fixed here so the tasks agree:
33 33
34--- 34---
35 35
36### Task 1: Migration 0053 and the store 36### Task 1: Migration 0054 and the store
37 37
38**Files:** 38**Files:**
39- Create: `internal/store/migrations/0053_snippets.up.sql` 39- Create: `internal/store/migrations/0054_snippets.up.sql`
40- Create: `internal/store/migrations/0053_snippets.down.sql` 40- Create: `internal/store/migrations/0054_snippets.down.sql`
41- Create: `internal/store/snippets.go` 41- Create: `internal/store/snippets.go`
42- Test: `internal/store/snippets_test.go` 42- Test: `internal/store/snippets_test.go`
43 43
@@ -193,7 +193,7 @@ Expected: compile error, `s.CreateSnippet undefined`.
193 193
194- [ ] **Step 3: Write the migration** 194- [ ] **Step 3: Write the migration**
195 195
196`internal/store/migrations/0053_snippets.up.sql`: 196`internal/store/migrations/0054_snippets.up.sql`:
197 197
198```sql 198```sql
199-- Snippets: named text files a user owns and shares by URL, outside any 199-- Snippets: named text files a user owns and shares by URL, outside any
@@ -218,7 +218,7 @@ CREATE TABLE snippet_files (
218); 218);
219``` 219```
220 220
221`internal/store/migrations/0053_snippets.down.sql`: 221`internal/store/migrations/0054_snippets.down.sql`:
222 222
223```sql 223```sql
224DROP TABLE snippet_files; 224DROP TABLE snippet_files;
@@ -463,8 +463,8 @@ Expected: PASS, including `TestMigrateUpDown` (the down file drops both tables)
463- [ ] **Step 6: Commit** 463- [ ] **Step 6: Commit**
464 464
465```bash 465```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 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 0053) 467git commit -m "store: snippets and snippet_files (migration 0054)
468 468
469Ref #195" 469Ref #195"
470``` 470```
@@ -1857,7 +1857,7 @@ Before `* v1.19.0 — 2026-09-11` add:
1857Snippets (#195): named text files a user owns outside any repository, 1857Snippets (#195): named text files a user owns outside any repository,
1858shared by URL and edited in place. 1858shared by URL and edited in place.
1859 1859
1860- Migration 0053: =snippets= and =snippet_files=. 1860- Migration 0054: =snippets= and =snippet_files=.
1861- =snippet create|show|list|edit|delete= and =snippet file 1861- =snippet create|show|list|edit|delete= and =snippet file
1862 set|get|remove=. Files are UTF-8 under =limits.max_snippet_bytes= 1862 set|get|remove=. Files are UTF-8 under =limits.max_snippet_bytes=
1863 (1MB), at most 64 per snippet; a snippet keeps at least one. 1863 (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
1890Named text files a user owns outside any repository, shared by URL and 1890Named text files a user owns outside any repository, shared by URL and
1891edited in place. Spec: docs/specs/2026-09-11-snippets-design.md. 1891edited in place. Spec: docs/specs/2026-09-11-snippets-design.md.
1892 1892
1893Migration 0053. Commands snippet create|show|list|edit|delete and 1893Migration 0054. Commands snippet create|show|list|edit|delete and
1894snippet file set|get|remove; web under /{owner}/-/snippets with forms 1894snippet file set|get|remove; web under /{owner}/-/snippets with forms
1895dispatching the same commands. New limit max_snippet_bytes (1MB). 1895dispatching the same commands. New limit max_snippet_bytes (1MB).
1896 1896
docs/specs/2026-09-11-snippets-design.md +1 −1
@@ -57,7 +57,7 @@ Decisions taken on the way, with the alternatives rejected:
57 57
58## Data 58## Data
59 59
60Migration 0053, no rebuild: 60Migration 0054, no rebuild:
61 61
62```sql 62```sql
63CREATE TABLE snippets ( 63CREATE 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