From 5078b41499f6ef227ce3ed272db203d0f9229e83 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sat, 16 Nov 2024 07:43:54 +0100 Subject: [PATCH] `core`: Add `subject` column --- acrate-core/migrations/2024-11-14-031744_meta/up.sql | 6 ++++++ acrate-core/src/meta.rs | 1 + acrate-core/src/schema.rs | 1 + 3 files changed, 8 insertions(+) diff --git a/acrate-core/migrations/2024-11-14-031744_meta/up.sql b/acrate-core/migrations/2024-11-14-031744_meta/up.sql index 8387ac9..85da6e3 100644 --- a/acrate-core/migrations/2024-11-14-031744_meta/up.sql +++ b/acrate-core/migrations/2024-11-14-031744_meta/up.sql @@ -2,8 +2,14 @@ CREATE TABLE IF NOT EXISTS meta_subjects ( id UUID DEFAULT gen_random_uuid(), document BPCHAR NOT NULL, pattern BPCHAR NOT NULL, + subject BPCHAR, redirect BPCHAR, + CONSTRAINT either_subject_or_redirect_not_null CHECK ( + (subject IS NOT NULL AND redirect IS NULL) + OR + (subject IS NULL AND redirect IS NOT NULL) + ), PRIMARY KEY (id) ); diff --git a/acrate-core/src/meta.rs b/acrate-core/src/meta.rs index 4fe0343..f4d8c60 100644 --- a/acrate-core/src/meta.rs +++ b/acrate-core/src/meta.rs @@ -11,6 +11,7 @@ pub struct MetaSubject { pub id: Uuid, pub document: String, pub pattern: String, + pub subject: Option, pub redirect: Option, } diff --git a/acrate-core/src/schema.rs b/acrate-core/src/schema.rs index 94b2aa7..bf27173 100644 --- a/acrate-core/src/schema.rs +++ b/acrate-core/src/schema.rs @@ -55,6 +55,7 @@ diesel::table! { id -> Uuid, document -> Bpchar, pattern -> Bpchar, + subject -> Nullable, redirect -> Nullable, } }