core
: Create migration for metadata tables
This commit is contained in:
parent
025311e100
commit
2d3421e2c3
5 changed files with 119 additions and 0 deletions
12
.idea/dataSources.xml
Normal file
12
.idea/dataSources.xml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
|
||||||
|
<data-source source="LOCAL" name="acrate" uuid="8258414e-095d-430b-a0a5-b48e72af23a9">
|
||||||
|
<driver-ref>postgresql</driver-ref>
|
||||||
|
<synchronize>true</synchronize>
|
||||||
|
<jdbc-driver>org.postgresql.Driver</jdbc-driver>
|
||||||
|
<jdbc-url>jdbc:postgresql:///acrate</jdbc-url>
|
||||||
|
<working-dir>$ProjectFileDir$</working-dir>
|
||||||
|
</data-source>
|
||||||
|
</component>
|
||||||
|
</project>
|
6
.idea/sqldialects.xml
Normal file
6
.idea/sqldialects.xml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="SqlDialectMappings">
|
||||||
|
<file url="file://$PROJECT_DIR$/acrate-core/migrations/2024-11-14-031744_Add webfinger table/up.sql" dialect="GenericSQL" />
|
||||||
|
</component>
|
||||||
|
</project>
|
|
@ -0,0 +1,8 @@
|
||||||
|
DROP FUNCTION get_meta_property;
|
||||||
|
DROP FUNCTION get_meta_link;
|
||||||
|
DROP FUNCTION get_meta_aliases;
|
||||||
|
|
||||||
|
DROP TABLE meta_property;
|
||||||
|
DROP TABLE meta_link_property;
|
||||||
|
DROP TABLE meta_link;
|
||||||
|
DROP TABLE meta_alias;
|
|
@ -0,0 +1,47 @@
|
||||||
|
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;
|
46
acrate-core/src/schema.rs
Normal file
46
acrate-core/src/schema.rs
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
// @generated automatically by Diesel CLI.
|
||||||
|
|
||||||
|
diesel::table! {
|
||||||
|
meta_alias (id) {
|
||||||
|
id -> Uuid,
|
||||||
|
pattern -> Bpchar,
|
||||||
|
alias -> Bpchar,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
diesel::table! {
|
||||||
|
meta_link (id) {
|
||||||
|
id -> Uuid,
|
||||||
|
pattern -> Bpchar,
|
||||||
|
rel -> Bpchar,
|
||||||
|
#[sql_name = "type"]
|
||||||
|
type_ -> Nullable<Bpchar>,
|
||||||
|
href -> Nullable<Bpchar>,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
diesel::table! {
|
||||||
|
meta_link_property (id) {
|
||||||
|
id -> Uuid,
|
||||||
|
link -> Nullable<Uuid>,
|
||||||
|
rel -> Bpchar,
|
||||||
|
value -> Nullable<Bpchar>,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
diesel::table! {
|
||||||
|
meta_property (id) {
|
||||||
|
id -> Uuid,
|
||||||
|
pattern -> Bpchar,
|
||||||
|
value -> Nullable<Bpchar>,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
diesel::joinable!(meta_link_property -> meta_link (link));
|
||||||
|
|
||||||
|
diesel::allow_tables_to_appear_in_same_query!(
|
||||||
|
meta_alias,
|
||||||
|
meta_link,
|
||||||
|
meta_link_property,
|
||||||
|
meta_property,
|
||||||
|
);
|
Loading…
Reference in a new issue