From f2d73c1798976cb9314fd9f497d62ef7ce532fe6 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 15 Nov 2024 20:48:51 +0100 Subject: [PATCH] `core`: Further schema improvements --- .../migrations/2024-11-14-031744_meta/down.sql | 1 + .../migrations/2024-11-14-031744_meta/up.sql | 14 +++++++------- acrate-core/src/schema.rs | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/acrate-core/migrations/2024-11-14-031744_meta/down.sql b/acrate-core/migrations/2024-11-14-031744_meta/down.sql index 9b62cb9..2c09392 100644 --- a/acrate-core/migrations/2024-11-14-031744_meta/down.sql +++ b/acrate-core/migrations/2024-11-14-031744_meta/down.sql @@ -1,4 +1,5 @@ DROP TABLE IF EXISTS meta_properties CASCADE; DROP TABLE IF EXISTS meta_link_properties CASCADE; +DROP TABLE IF EXISTS meta_link_titles CASCADE; DROP TABLE IF EXISTS meta_links CASCADE; DROP TABLE IF EXISTS meta_aliases CASCADE; 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 b258ed4..012feab 100644 --- a/acrate-core/migrations/2024-11-14-031744_meta/up.sql +++ b/acrate-core/migrations/2024-11-14-031744_meta/up.sql @@ -1,4 +1,4 @@ -CREATE TABLE meta_aliases ( +CREATE TABLE IF NOT EXISTS meta_aliases ( id UUID DEFAULT gen_random_uuid(), document BPCHAR NOT NULL, pattern BPCHAR NOT NULL, @@ -7,7 +7,7 @@ CREATE TABLE meta_aliases ( PRIMARY KEY (id) ); -CREATE TABLE meta_links ( +CREATE TABLE IF NOT EXISTS meta_links ( id UUID DEFAULT gen_random_uuid(), document BPCHAR NOT NULL, pattern BPCHAR NOT NULL, @@ -24,7 +24,7 @@ CREATE TABLE meta_links ( PRIMARY KEY (id) ); -CREATE TABLE meta_link_properties ( +CREATE TABLE IF NOT EXISTS meta_link_properties ( id UUID DEFAULT gen_random_uuid(), meta_link_id UUID REFERENCES meta_links (id) NOT NULL, rel BPCHAR NOT NULL, @@ -33,7 +33,7 @@ CREATE TABLE meta_link_properties ( PRIMARY KEY (id) ); -CREATE TABLE meta_properties ( +CREATE TABLE IF NOT EXISTS meta_properties ( id UUID DEFAULT gen_random_uuid(), document BPCHAR NOT NULL, pattern BPCHAR NOT NULL, @@ -43,12 +43,12 @@ CREATE TABLE meta_properties ( PRIMARY KEY (id) ); -CREATE TABLE meta_link_titles ( +CREATE TABLE IF NOT EXISTS meta_link_titles ( id UUID DEFAULT gen_random_uuid(), meta_link_id UUID REFERENCES meta_links (id) NOT NULL, - lang BPCHAR NOT NULL DEFAULT 'und', + language BPCHAR NOT NULL DEFAULT 'und', value BPCHAR NOT NULL, - CONSTRAINT unique_languages UNIQUE (meta_link_id, lang), + CONSTRAINT unique_languages UNIQUE (meta_link_id, language), PRIMARY KEY(id) ); diff --git a/acrate-core/src/schema.rs b/acrate-core/src/schema.rs index 6cd2df7..e6544b5 100644 --- a/acrate-core/src/schema.rs +++ b/acrate-core/src/schema.rs @@ -22,7 +22,7 @@ diesel::table! { meta_link_titles (id) { id -> Uuid, meta_link_id -> Uuid, - lang -> Bpchar, + language -> Bpchar, value -> Bpchar, } }