Files
homebrewery-oidc/server/storage/postgres/migrations/0003_brew_assets.js
T

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);
};