1
Fork 0

core: Update schema with more details

This commit is contained in:
Steffo 2024-11-15 20:43:41 +01:00
parent c36b6edbfb
commit e5412d85ba
Signed by: steffo
GPG key ID: 5ADA3868646C3FC0
2 changed files with 30 additions and 2 deletions

View file

@ -4,7 +4,6 @@ CREATE TABLE meta_aliases (
pattern BPCHAR NOT NULL, pattern BPCHAR NOT NULL,
alias BPCHAR NOT NULL, alias BPCHAR NOT NULL,
CONSTRAINT unique_aliases UNIQUE (alias),
PRIMARY KEY (id) PRIMARY KEY (id)
); );
@ -15,7 +14,13 @@ CREATE TABLE meta_links (
rel BPCHAR NOT NULL, rel BPCHAR NOT NULL,
type BPCHAR, type BPCHAR,
href 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) PRIMARY KEY (id)
); );
@ -37,3 +42,13 @@ CREATE TABLE meta_properties (
PRIMARY KEY (id) 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)
);

View file

@ -18,14 +18,25 @@ diesel::table! {
} }
} }
diesel::table! {
meta_link_titles (id) {
id -> Uuid,
meta_link_id -> Uuid,
lang -> Bpchar,
value -> Bpchar,
}
}
diesel::table! { diesel::table! {
meta_links (id) { meta_links (id) {
id -> Uuid, id -> Uuid,
document -> Bpchar, document -> Bpchar,
pattern -> Bpchar, pattern -> Bpchar,
rel -> Bpchar, rel -> Bpchar,
r#type -> Nullable<Bpchar>, #[sql_name = "type"]
type_ -> Nullable<Bpchar>,
href -> Nullable<Bpchar>, href -> Nullable<Bpchar>,
template -> Nullable<Bpchar>,
} }
} }
@ -40,10 +51,12 @@ diesel::table! {
} }
diesel::joinable!(meta_link_properties -> meta_links (meta_link_id)); 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!( diesel::allow_tables_to_appear_in_same_query!(
meta_aliases, meta_aliases,
meta_link_properties, meta_link_properties,
meta_link_titles,
meta_links, meta_links,
meta_properties, meta_properties,
); );