feat: add basic graphql support

This commit is contained in:
2025-01-04 20:38:41 +08:00
parent caaa5dc0cc
commit 40cbf86f0f
62 changed files with 4053 additions and 675 deletions

View File

@@ -1,5 +1,6 @@
use std::collections::HashSet;
use async_trait::async_trait;
use sea_orm::{DeriveIden, Statement};
use sea_orm_migration::prelude::{extension::postgres::IntoTypeRef, *};
@@ -143,7 +144,7 @@ macro_rules! create_postgres_enum_for_active_enum {
};
}
#[async_trait::async_trait]
#[async_trait]
pub trait CustomSchemaManagerExt {
async fn create_postgres_auto_update_ts_fn(&self, col_name: &str) -> Result<(), DbErr>;
async fn create_postgres_auto_update_ts_fn_for_col<C: IntoIden + 'static + Send>(
@@ -250,7 +251,7 @@ pub trait CustomSchemaManagerExt {
) -> Result<HashSet<String>, DbErr>;
}
#[async_trait::async_trait]
#[async_trait]
impl CustomSchemaManagerExt for SchemaManager<'_> {
async fn create_postgres_auto_update_ts_fn(&self, col_name: &str) -> Result<(), DbErr> {
let sql = format!(

View File

@@ -1,3 +1,4 @@
use async_trait::async_trait;
use loco_rs::schema::jsonb_null;
use sea_orm_migration::{prelude::*, schema::*};
@@ -13,7 +14,7 @@ use crate::models::{
#[derive(DeriveMigrationName)]
pub struct Migration;
#[async_trait::async_trait]
#[async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager

View File

@@ -1,25 +1,24 @@
use async_trait::async_trait;
use loco_rs::schema::table_auto;
use sea_orm_migration::{prelude::*, schema::*};
use super::defs::*;
use crate::models::{
downloaders::DownloaderCategoryEnum,
prelude::{
downloads::{DownloadMimeEnum, DownloadStatusEnum},
DownloadMime, DownloadStatus, DownloaderCategory,
},
downloaders::{DownloaderCategory, DownloaderCategoryEnum},
downloads::{DownloadMime, DownloadMimeEnum, DownloadStatus, DownloadStatusEnum},
};
#[derive(DeriveMigrationName)]
pub struct Migration;
#[async_trait::async_trait]
#[async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
create_postgres_enum_for_active_enum!(
manager,
DownloaderCategoryEnum,
DownloaderCategory::QBittorrent
DownloaderCategory::QBittorrent,
DownloaderCategory::Dandanplay
)
.await?;

View File

@@ -8,7 +8,7 @@ use crate::{
#[derive(DeriveMigrationName)]
pub struct Migration;
#[async_trait::async_trait]
#[async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
create_postgres_enum_for_active_enum!(

View File

@@ -1,3 +1,4 @@
use async_trait::async_trait;
use sea_orm_migration::{prelude::*, schema::*};
use super::defs::Auth;
@@ -12,7 +13,7 @@ use crate::{
#[derive(DeriveMigrationName)]
pub struct Migration;
#[async_trait::async_trait]
#[async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
create_postgres_enum_for_active_enum!(

View File

@@ -1,3 +1,4 @@
use async_trait::async_trait;
pub use sea_orm_migration::prelude::*;
#[macro_use]
@@ -8,7 +9,7 @@ pub mod m20241231_000001_auth;
pub struct Migrator;
#[async_trait::async_trait]
#[async_trait]
impl MigratorTrait for Migrator {
fn migrations() -> Vec<Box<dyn MigrationTrait>> {
vec![