Files
tora/db/schema.sql
T
2026-07-22 20:32:44 +02:00

24 lines
592 B
SQL

CREATE TYPE torrent_state AS ENUM (
'pending',
'downloading',
'paused',
'finished',
'error',
'stale'
);
CREATE TABLE torrents (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
info_hash TEXT NOT NULL UNIQUE,
name TEXT,
source TEXT NOT NULL,
output_path TEXT NOT NULL,
total_bytes BIGINT,
downloaded_bytes BIGINT NOT NULL DEFAULT 0,
state torrent_state NOT NULL DEFAULT 'pending',
error_message TEXT,
added_at TIMESTAMPTZ NOT NULL DEFAULT now(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
completed_at TIMESTAMPTZ
);