tirocinio-canali-steffo-acrate/acrate_database/migrations/2024-11-14-031744_meta/up.sql

70 lines
1.5 KiB
MySQL
Raw Normal View History

CREATE TABLE IF NOT EXISTS meta_subjects (
id UUID DEFAULT gen_random_uuid(),
document BPCHAR NOT NULL,
pattern BPCHAR NOT NULL,
2024-11-16 06:43:54 +00:00
subject BPCHAR,
2024-11-16 05:45:58 +00:00
redirect BPCHAR,
2024-11-16 06:43:54 +00:00
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)
);
2024-11-15 19:48:51 +00:00
CREATE TABLE IF NOT EXISTS meta_aliases (
id UUID DEFAULT gen_random_uuid(),
document BPCHAR NOT NULL,
pattern BPCHAR NOT NULL,
alias BPCHAR NOT NULL,
PRIMARY KEY (id)
);
2024-11-15 19:48:51 +00:00
CREATE TABLE IF NOT EXISTS meta_links (
id UUID DEFAULT gen_random_uuid(),
document BPCHAR NOT NULL,
pattern BPCHAR NOT NULL,
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)
);
2024-11-15 19:48:51 +00:00
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,
value BPCHAR,
PRIMARY KEY (id)
);
2024-11-15 19:48:51 +00:00
CREATE TABLE IF NOT EXISTS meta_properties (
id UUID DEFAULT gen_random_uuid(),
document BPCHAR NOT NULL,
pattern BPCHAR NOT NULL,
rel BPCHAR NOT NULL,
value BPCHAR,
PRIMARY KEY (id)
);
2024-11-15 19:48:51 +00:00
CREATE TABLE IF NOT EXISTS meta_link_titles (
id UUID DEFAULT gen_random_uuid(),
meta_link_id UUID REFERENCES meta_links (id) NOT NULL,
2024-11-15 19:48:51 +00:00
language BPCHAR NOT NULL DEFAULT 'und',
value BPCHAR NOT NULL,
2024-11-15 19:48:51 +00:00
CONSTRAINT unique_languages UNIQUE (meta_link_id, language),
PRIMARY KEY(id)
);