1
Fork 0
tirocinio-canali-steffo-acrate/acrate-core/migrations/2024-11-14-031744_meta/up.sql

48 lines
1.1 KiB
MySQL
Raw Normal View History

2024-11-15 01:04:15 +00:00
CREATE TABLE meta_aliases (
id UUID DEFAULT gen_random_uuid(),
pattern BPCHAR NOT NULL,
alias BPCHAR NOT NULL,
CONSTRAINT unique_aliases UNIQUE (alias),
PRIMARY KEY (id)
);
2024-11-15 01:04:15 +00:00
CREATE TABLE meta_links (
id UUID DEFAULT gen_random_uuid(),
pattern BPCHAR NOT NULL,
rel BPCHAR NOT NULL,
type BPCHAR,
href BPCHAR,
PRIMARY KEY (id)
);
2024-11-15 01:04:15 +00:00
CREATE TABLE meta_link_properties (
id UUID DEFAULT gen_random_uuid(),
link UUID REFERENCES meta_link (id),
rel BPCHAR NOT NULL,
value BPCHAR,
PRIMARY KEY (id)
);
2024-11-15 01:04:15 +00:00
CREATE TABLE meta_properties (
id UUID DEFAULT gen_random_uuid(),
pattern BPCHAR NOT NULL,
value BPCHAR,
PRIMARY KEY (id)
);
CREATE FUNCTION get_meta_aliases(BPCHAR) RETURNS SETOF meta_alias AS $$
2024-11-15 01:04:15 +00:00
SELECT * FROM meta_aliases WHERE meta_aliases.pattern ILIKE $1;
$$ LANGUAGE SQL;
2024-11-15 01:04:15 +00:00
CREATE FUNCTION get_meta_links(BPCHAR) RETURNS SETOF meta_link AS $$
SELECT * FROM meta_links WHERE meta_links.pattern ILIKE $1;
$$ LANGUAGE SQL;
CREATE FUNCTION get_meta_property(BPCHAR) RETURNS SETOF meta_property AS $$
2024-11-15 01:04:15 +00:00
SELECT * FROM meta_properties WHERE meta_properties.pattern ILIKE $1;
$$ LANGUAGE SQL;