47 lines
1.1 KiB
PL/PgSQL
47 lines
1.1 KiB
PL/PgSQL
CREATE TABLE meta_alias (
|
|
id UUID DEFAULT gen_random_uuid(),
|
|
pattern BPCHAR NOT NULL,
|
|
alias BPCHAR NOT NULL,
|
|
|
|
CONSTRAINT unique_aliases UNIQUE (alias),
|
|
PRIMARY KEY (id)
|
|
);
|
|
|
|
CREATE TABLE meta_link (
|
|
id UUID DEFAULT gen_random_uuid(),
|
|
pattern BPCHAR NOT NULL,
|
|
rel BPCHAR NOT NULL,
|
|
type BPCHAR,
|
|
href BPCHAR,
|
|
|
|
PRIMARY KEY (id)
|
|
);
|
|
|
|
CREATE TABLE meta_link_property (
|
|
id UUID DEFAULT gen_random_uuid(),
|
|
link UUID REFERENCES meta_link (id),
|
|
rel BPCHAR NOT NULL,
|
|
value BPCHAR,
|
|
|
|
PRIMARY KEY (id)
|
|
);
|
|
|
|
CREATE TABLE meta_property (
|
|
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 $$
|
|
SELECT * FROM meta_alias WHERE meta_alias.pattern ILIKE $1;
|
|
$$ LANGUAGE SQL;
|
|
|
|
CREATE FUNCTION get_meta_link(BPCHAR) RETURNS SETOF meta_link AS $$
|
|
SELECT * FROM meta_link WHERE meta_link.pattern ILIKE $1;
|
|
$$ LANGUAGE SQL;
|
|
|
|
CREATE FUNCTION get_meta_property(BPCHAR) RETURNS SETOF meta_property AS $$
|
|
SELECT * FROM meta_property WHERE meta_property.pattern ILIKE $1;
|
|
$$ LANGUAGE SQL;
|