From 8da4e5e840a338ed6db323d100e3f31913966c1e Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Fri, 9 May 2025 22:48:40 +0200 Subject: [PATCH] Create request migration --- scanner/migrations/000001_request.down.sql | 7 +++++++ scanner/migrations/000001_request.up.sql | 18 ++++++++++++++++++ scanner/shell.nix | 2 ++ 3 files changed, 27 insertions(+) create mode 100644 scanner/migrations/000001_request.down.sql create mode 100644 scanner/migrations/000001_request.up.sql diff --git a/scanner/migrations/000001_request.down.sql b/scanner/migrations/000001_request.down.sql new file mode 100644 index 00000000..3a175421 --- /dev/null +++ b/scanner/migrations/000001_request.down.sql @@ -0,0 +1,7 @@ +begin; + +drop table scanner.requests; +drop type scanner.request_kind; + +commit; + diff --git a/scanner/migrations/000001_request.up.sql b/scanner/migrations/000001_request.up.sql new file mode 100644 index 00000000..5ab9e1a8 --- /dev/null +++ b/scanner/migrations/000001_request.up.sql @@ -0,0 +1,18 @@ +begin; + +create type scanner.request_kind as enum('episode', 'movie'); + +create table scanner.requests( + pk serial primary key, + id uuid not null default gen_random_uuid() unique, + kind scanner.request_kind not null, + title text not null, + year integer, + external_id jsonb not null default '{}'::jsonb, + + created_at timestamptz not null default now()::timestamptz, + + constraint unique_kty (kind, title, year) +); + +commit; diff --git a/scanner/shell.nix b/scanner/shell.nix index 04851876..0b62e6c8 100644 --- a/scanner/shell.nix +++ b/scanner/shell.nix @@ -8,6 +8,7 @@ watchfiles langcodes psycopg + psycopg-pool ]); in pkgs.mkShell { @@ -15,5 +16,6 @@ in python ruff fastapi-cli + pgformatter ]; }