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 1b7f236..b258ed4 100644 --- a/acrate-core/migrations/2024-11-14-031744_meta/up.sql +++ b/acrate-core/migrations/2024-11-14-031744_meta/up.sql @@ -4,7 +4,6 @@ CREATE TABLE meta_aliases ( pattern BPCHAR NOT NULL, alias BPCHAR NOT NULL, - CONSTRAINT unique_aliases UNIQUE (alias), PRIMARY KEY (id) ); @@ -15,7 +14,13 @@ CREATE TABLE meta_links ( rel BPCHAR NOT NULL, type BPCHAR, href BPCHAR, + template BPCHAR, + CONSTRAINT either_href_or_template_not_null CHECK ( + (href IS NOT NULL AND template IS NULL) + OR + (href IS NULL AND template IS NOT NULL) + ), PRIMARY KEY (id) ); @@ -37,3 +42,13 @@ CREATE TABLE meta_properties ( PRIMARY KEY (id) ); + +CREATE TABLE 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', + value BPCHAR NOT NULL, + + CONSTRAINT unique_languages UNIQUE (meta_link_id, lang), + PRIMARY KEY(id) +); diff --git a/acrate-core/src/schema.rs b/acrate-core/src/schema.rs index cbee252..6cd2df7 100644 --- a/acrate-core/src/schema.rs +++ b/acrate-core/src/schema.rs @@ -18,14 +18,25 @@ diesel::table! { } } +diesel::table! { + meta_link_titles (id) { + id -> Uuid, + meta_link_id -> Uuid, + lang -> Bpchar, + value -> Bpchar, + } +} + diesel::table! { meta_links (id) { id -> Uuid, document -> Bpchar, pattern -> Bpchar, rel -> Bpchar, - r#type -> Nullable, + #[sql_name = "type"] + type_ -> Nullable, href -> Nullable, + template -> Nullable, } } @@ -40,10 +51,12 @@ diesel::table! { } diesel::joinable!(meta_link_properties -> meta_links (meta_link_id)); +diesel::joinable!(meta_link_titles -> meta_links (meta_link_id)); diesel::allow_tables_to_appear_in_same_query!( meta_aliases, meta_link_properties, + meta_link_titles, meta_links, meta_properties, );