oficina / docs Public

Clone
git clone https://amadan.net/oficina/docs

Plain git — no account needed to clone.

Download

Download this file

1CREATE TABLE IF NOT EXISTS people (
2 id INTEGER PRIMARY KEY,
3 email TEXT NOT NULL UNIQUE,
4 created_at DATETIME NOT NULL
5);
6
7-- DEFAULT 0 is a deliberate decision, not a placeholder: SQLite's
8-- INTEGER PRIMARY KEY on people.id starts at 1, so owner_id = 0 can
9-- never match a real person. Any document that existed before this
10-- migration ran is backfilled to owner_id = 0 and becomes permanently
11-- invisible through Store (store.go's owned() explicitly matches
12-- nothing for owner <= 0, so no future caller can accidentally expose
13-- these rows either) -- there is no live deployment yet (this plan is
14-- what takes Docs live for the first time), so today that set is
15-- empty in practice, but the behaviour is real and permanent for
16-- anyone who runs this migration against a database that already has
17-- rows: those documents are orphaned on purpose, not lost by oversight.
18-- Pinned by TestOrphanedDocumentsAreVisibleToNobody in scope_test.go.
19ALTER TABLE documents ADD COLUMN owner_id INTEGER NOT NULL DEFAULT 0;
20
21CREATE INDEX IF NOT EXISTS idx_documents_owner_id ON documents (owner_id);
22