core
: Fix schema
This commit is contained in:
parent
c83fdc43e6
commit
7f392bef36
3 changed files with 15 additions and 9 deletions
|
@ -2,7 +2,7 @@ CREATE TABLE IF NOT EXISTS meta_subjects (
|
|||
id UUID DEFAULT gen_random_uuid(),
|
||||
document BPCHAR NOT NULL,
|
||||
pattern BPCHAR NOT NULL,
|
||||
redirect BPCHAR NOT NULL,
|
||||
redirect BPCHAR,
|
||||
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use diesel::{Associations, Identifiable, Insertable, QueryResult, Queryable, QueryableByName, Selectable};
|
||||
use diesel::{Associations, Identifiable, Insertable, QueryResult, Queryable, QueryableByName, Selectable, pg::Pg};
|
||||
use diesel_async::AsyncPgConnection;
|
||||
use uuid::Uuid;
|
||||
use super::schema;
|
||||
|
@ -6,6 +6,7 @@ use super::schema;
|
|||
|
||||
#[derive(Debug, Queryable, QueryableByName, Identifiable, Selectable, Insertable)]
|
||||
#[diesel(table_name = schema::meta_subjects)]
|
||||
#[diesel(check_for_backend(Pg))]
|
||||
pub struct MetaSubject {
|
||||
pub id: Uuid,
|
||||
pub document: String,
|
||||
|
@ -15,6 +16,7 @@ pub struct MetaSubject {
|
|||
|
||||
#[derive(Debug, Queryable, QueryableByName, Identifiable, Selectable, Insertable)]
|
||||
#[diesel(table_name = schema::meta_aliases)]
|
||||
#[diesel(check_for_backend(Pg))]
|
||||
pub struct MetaAlias {
|
||||
pub id: Uuid,
|
||||
pub document: String,
|
||||
|
@ -24,6 +26,7 @@ pub struct MetaAlias {
|
|||
|
||||
#[derive(Debug, Queryable, QueryableByName, Identifiable, Selectable, Insertable)]
|
||||
#[diesel(table_name = schema::meta_links)]
|
||||
#[diesel(check_for_backend(Pg))]
|
||||
pub struct MetaLink {
|
||||
pub id: Uuid,
|
||||
pub document: String,
|
||||
|
@ -37,6 +40,7 @@ pub struct MetaLink {
|
|||
#[derive(Debug, Queryable, QueryableByName, Identifiable, Selectable, Insertable, Associations)]
|
||||
#[diesel(belongs_to(MetaLink))]
|
||||
#[diesel(table_name = schema::meta_link_properties)]
|
||||
#[diesel(check_for_backend(Pg))]
|
||||
pub struct MetaLinkProperty {
|
||||
pub id: Uuid,
|
||||
pub meta_link_id: Uuid,
|
||||
|
@ -47,6 +51,7 @@ pub struct MetaLinkProperty {
|
|||
#[derive(Debug, Queryable, QueryableByName, Identifiable, Selectable, Insertable, Associations)]
|
||||
#[diesel(belongs_to(MetaLink))]
|
||||
#[diesel(table_name = schema::meta_link_titles)]
|
||||
#[diesel(check_for_backend(Pg))]
|
||||
pub struct MetaLinkTitle {
|
||||
pub id: Uuid,
|
||||
pub meta_link_id: Uuid,
|
||||
|
@ -56,6 +61,7 @@ pub struct MetaLinkTitle {
|
|||
|
||||
#[derive(Debug, Queryable, QueryableByName, Identifiable, Selectable, Insertable)]
|
||||
#[diesel(table_name = schema::meta_properties)]
|
||||
#[diesel(check_for_backend(Pg))]
|
||||
pub struct MetaProperty {
|
||||
pub id: Uuid,
|
||||
pub document: String,
|
||||
|
@ -65,7 +71,7 @@ pub struct MetaProperty {
|
|||
}
|
||||
|
||||
impl MetaSubject {
|
||||
pub async fn query_matching(conn: &mut AsyncPgConnection, doc: &str, subject: &str) -> QueryResult<Vec<MetaSubject>> {
|
||||
pub async fn query_matching(conn: &mut AsyncPgConnection, doc: &str, subject: &str) -> QueryResult<Vec<Self>> {
|
||||
use diesel::prelude::*;
|
||||
use diesel_async::RunQueryDsl;
|
||||
use schema::meta_subjects::dsl::*;
|
||||
|
@ -83,7 +89,7 @@ impl MetaSubject {
|
|||
}
|
||||
|
||||
impl MetaAlias {
|
||||
pub async fn query_matching(conn: &mut AsyncPgConnection, doc: &str, subject: &str) -> QueryResult<Vec<MetaAlias>> {
|
||||
pub async fn query_matching(conn: &mut AsyncPgConnection, doc: &str, subject: &str) -> QueryResult<Vec<Self>> {
|
||||
use diesel::prelude::*;
|
||||
use diesel_async::RunQueryDsl;
|
||||
use schema::meta_aliases::dsl::*;
|
||||
|
@ -101,7 +107,7 @@ impl MetaAlias {
|
|||
}
|
||||
|
||||
impl MetaLink {
|
||||
pub async fn query_matching(conn: &mut AsyncPgConnection, doc: &str, subject: &str) -> QueryResult<Vec<MetaLink>> {
|
||||
pub async fn query_matching(conn: &mut AsyncPgConnection, doc: &str, subject: &str) -> QueryResult<Vec<Self>> {
|
||||
use diesel::prelude::*;
|
||||
use diesel_async::RunQueryDsl;
|
||||
use schema::meta_links::dsl::*;
|
||||
|
@ -119,7 +125,7 @@ impl MetaLink {
|
|||
}
|
||||
|
||||
impl MetaLinkProperty {
|
||||
pub async fn query_by_link(conn: &mut AsyncPgConnection, links: &[MetaLink]) -> QueryResult<Vec<MetaLinkProperty>> {
|
||||
pub async fn query_by_link(conn: &mut AsyncPgConnection, links: &[MetaLink]) -> QueryResult<Vec<Self>> {
|
||||
use diesel::prelude::*;
|
||||
use diesel_async::RunQueryDsl;
|
||||
|
||||
|
@ -130,7 +136,7 @@ impl MetaLinkProperty {
|
|||
}
|
||||
|
||||
impl MetaLinkTitle {
|
||||
pub async fn query_by_link(conn: &mut AsyncPgConnection, links: &[MetaLink]) -> QueryResult<Vec<MetaLinkTitle>> {
|
||||
pub async fn query_by_link(conn: &mut AsyncPgConnection, links: &[MetaLink]) -> QueryResult<Vec<Self>> {
|
||||
use diesel::prelude::*;
|
||||
use diesel_async::RunQueryDsl;
|
||||
|
||||
|
@ -141,7 +147,7 @@ impl MetaLinkTitle {
|
|||
}
|
||||
|
||||
impl MetaProperty {
|
||||
pub async fn query_matching(conn: &mut AsyncPgConnection, doc: &str, subject: &str) -> QueryResult<Vec<MetaProperty>> {
|
||||
pub async fn query_matching(conn: &mut AsyncPgConnection, doc: &str, subject: &str) -> QueryResult<Vec<Self>> {
|
||||
use diesel::prelude::*;
|
||||
use diesel_async::RunQueryDsl;
|
||||
use schema::meta_properties::dsl::*;
|
||||
|
|
|
@ -55,7 +55,7 @@ diesel::table! {
|
|||
id -> Uuid,
|
||||
document -> Bpchar,
|
||||
pattern -> Bpchar,
|
||||
redirect -> Bpchar,
|
||||
redirect -> Nullable<Bpchar>,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue