diff --git a/acrate-core/migrations/2024-11-14-031744_meta/up.sql b/acrate-core/migrations/2024-11-14-031744_meta/up.sql index c0f6c46..8387ac9 100644 --- a/acrate-core/migrations/2024-11-14-031744_meta/up.sql +++ b/acrate-core/migrations/2024-11-14-031744_meta/up.sql @@ -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) ); diff --git a/acrate-core/src/meta.rs b/acrate-core/src/meta.rs index aca144c..4fe0343 100644 --- a/acrate-core/src/meta.rs +++ b/acrate-core/src/meta.rs @@ -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> { + pub async fn query_matching(conn: &mut AsyncPgConnection, doc: &str, subject: &str) -> QueryResult> { 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> { + pub async fn query_matching(conn: &mut AsyncPgConnection, doc: &str, subject: &str) -> QueryResult> { 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> { + pub async fn query_matching(conn: &mut AsyncPgConnection, doc: &str, subject: &str) -> QueryResult> { 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> { + pub async fn query_by_link(conn: &mut AsyncPgConnection, links: &[MetaLink]) -> QueryResult> { 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> { + pub async fn query_by_link(conn: &mut AsyncPgConnection, links: &[MetaLink]) -> QueryResult> { 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> { + pub async fn query_matching(conn: &mut AsyncPgConnection, doc: &str, subject: &str) -> QueryResult> { use diesel::prelude::*; use diesel_async::RunQueryDsl; use schema::meta_properties::dsl::*; diff --git a/acrate-core/src/schema.rs b/acrate-core/src/schema.rs index 4e9855d..94b2aa7 100644 --- a/acrate-core/src/schema.rs +++ b/acrate-core/src/schema.rs @@ -55,7 +55,7 @@ diesel::table! { id -> Uuid, document -> Bpchar, pattern -> Bpchar, - redirect -> Bpchar, + redirect -> Nullable, } }