0004_projects_credits.sql
This file
Path
apps/platform/migrations/0004_projects_credits.sql
35 lines · 1.3 KiB · SQL
Last changed by
Not known.
History of this fileTake it
The walk stopped after 200 commits: lines older than 678c8b8 point at it.
Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8
lines 1–35why, one step back1-- The project list and every person's credits, projected from each2-- project's outbox by packages/project/src/projection-d1 beside the front3-- page (its tables.ts holds this text). The projection is the only writer.45-- One row per project the projection has heard from: its posture, how many6-- asks it has open, and when the platform last landed on its main (absent7-- before its first landing).8CREATE TABLE projects (9 project TEXT PRIMARY KEY,10 posture TEXT NOT NULL,11 open_asks INTEGER NOT NULL,12 landed_at TEXT13);1415-- How many landings credit a person in one role, in one area of one16-- project: a count by role and area, never a score. `handle_key` is the17-- handle lowercased, the rule protocol's `sameHandle` compares by. The18-- primary key's index serves the lookup by person.19CREATE TABLE credits (20 handle_key TEXT NOT NULL,21 project TEXT NOT NULL,22 area TEXT NOT NULL,23 role TEXT NOT NULL,24 count INTEGER NOT NULL,25 PRIMARY KEY (handle_key, project, area, role)26);2728-- The projects 0001's tables already know of, each with its open asks, so29-- the list stays whole across this migration. On a fresh database it adds30-- nothing.31INSERT INTO projects (project, posture, open_asks, landed_at)32SELECT cursor.project, 'open',33 (SELECT COUNT(*) FROM front_page WHERE front_page.project = cursor.project),34 NULL35FROM cursor;