-- migrations/0001_notes.sql: each row is kept for the user who added it, its owner, with the time it was added. CREATE TABLE "notes" ( id bigserial PRIMARY KEY, owner text NOT NULL, created_at timestamptz NOT NULL DEFAULT now(), body text NOT NULL CHECK (char_length(btrim(body)) BETWEEN 1 AND 20000) ); CREATE INDEX ON "notes" (owner, created_at DESC, id DESC);