Upload-Endpunkt POST /api/git/brews/:editId/assets (Magic Bytes, konfigurierbare Limits HB_ASSET_*, Dedupe, Commit ins Repo, Snapshot in brew_assets) und Auslieferung /git-assets/:shareId/:sha256.:ext gemäß ADR 0004. Postgres-Migration 0003, Mongo-Repo, Editor-Button, Drag-and-drop und Einfügen. Closes #10 Co-authored-by: Dev (Paperclip) <dev-bot@noreply.git.morlana.online>
23 lines
745 B
JavaScript
23 lines
745 B
JavaScript
import { sql } from 'kysely';
|
|
|
|
// ADR 0004 §3: Snapshot der hochgeladenen Bilder, damit die App sie ohne Git-Zugriff ausliefert.
|
|
export const up = async (db)=>{
|
|
await sql`
|
|
CREATE TABLE brew_assets (
|
|
id uuid PRIMARY KEY DEFAULT uuidv7(),
|
|
brew_id uuid NOT NULL REFERENCES brews(id) ON DELETE CASCADE,
|
|
sha256 text NOT NULL CHECK (sha256 ~ '^[0-9a-f]{64}$'),
|
|
repo_path text NOT NULL,
|
|
commit_sha text NOT NULL,
|
|
content_type text NOT NULL,
|
|
size integer NOT NULL,
|
|
data bytea NOT NULL,
|
|
created_at timestamptz NOT NULL DEFAULT now(),
|
|
UNIQUE (brew_id, sha256)
|
|
)`.execute(db);
|
|
};
|
|
|
|
export const down = async (db)=>{
|
|
await sql`DROP TABLE IF EXISTS brew_assets`.execute(db);
|
|
};
|