From 8c6f859e9bb9fd84305a11beb80b5380206fb07b Mon Sep 17 00:00:00 2001 From: Mika Date: Sat, 19 Oct 2024 23:35:18 +0200 Subject: [PATCH] edit cli and removed old code --- crates/backend/src/old.rs | 16 ----- crates/entity/src/lib.rs | 2 - crates/entity/src/post.rs | 18 ----- crates/entity/src/prelude.rs | 2 - crates/entity/src/zehner.rs | 18 ----- crates/migration/src/lib.rs | 2 - .../src/m20220101_000001_create_table.rs | 70 ------------------- crates/xtask/src/main.rs | 29 ++++++++ 8 files changed, 29 insertions(+), 128 deletions(-) delete mode 100644 crates/backend/src/old.rs delete mode 100644 crates/entity/src/post.rs delete mode 100644 crates/entity/src/zehner.rs delete mode 100644 crates/migration/src/m20220101_000001_create_table.rs diff --git a/crates/backend/src/old.rs b/crates/backend/src/old.rs deleted file mode 100644 index 8fb0caf..0000000 --- a/crates/backend/src/old.rs +++ /dev/null @@ -1,16 +0,0 @@ -use entity::zehner; -use sea_orm::{ActiveValue, Database}; - -fn old() { - let model = zehner::ActiveModel { - id: ActiveValue::not_set(), - title: ActiveValue::set(String::from("Mika ist der doof")), - text: ActiveValue::set(Some("Johannes ist auch dabei".to_owned())), - }; - - model.insert(&conn).await.unwrap(); - - let result = zehner::Entity::find().all(&conn).await.unwrap(); - - println!("{:#?}", result); -} diff --git a/crates/entity/src/lib.rs b/crates/entity/src/lib.rs index 74c495b..bd5662b 100644 --- a/crates/entity/src/lib.rs +++ b/crates/entity/src/lib.rs @@ -3,6 +3,4 @@ pub mod prelude; pub mod documents; -pub mod post; pub mod users; -pub mod zehner; diff --git a/crates/entity/src/post.rs b/crates/entity/src/post.rs deleted file mode 100644 index ac8706c..0000000 --- a/crates/entity/src/post.rs +++ /dev/null @@ -1,18 +0,0 @@ -//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.1 - -use sea_orm::entity::prelude::*; -use serde::{Deserialize, Serialize}; - -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] -#[sea_orm(table_name = "post")] -pub struct Model { - #[sea_orm(primary_key)] - pub id: i32, - pub title: String, - pub text: String, -} - -#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] -pub enum Relation {} - -impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/entity/src/prelude.rs b/crates/entity/src/prelude.rs index c2af866..5adff5c 100644 --- a/crates/entity/src/prelude.rs +++ b/crates/entity/src/prelude.rs @@ -1,6 +1,4 @@ //! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.1 pub use super::documents::Entity as Documents; -pub use super::post::Entity as Post; pub use super::users::Entity as Users; -pub use super::zehner::Entity as Zehner; diff --git a/crates/entity/src/zehner.rs b/crates/entity/src/zehner.rs deleted file mode 100644 index f027084..0000000 --- a/crates/entity/src/zehner.rs +++ /dev/null @@ -1,18 +0,0 @@ -//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.1 - -use sea_orm::entity::prelude::*; -use serde::{Deserialize, Serialize}; - -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] -#[sea_orm(table_name = "zehner")] -pub struct Model { - #[sea_orm(primary_key, auto_increment = false)] - pub id: Uuid, - pub title: String, - pub text: Option, -} - -#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] -pub enum Relation {} - -impl ActiveModelBehavior for ActiveModel {} diff --git a/crates/migration/src/lib.rs b/crates/migration/src/lib.rs index 60fd131..c65011e 100644 --- a/crates/migration/src/lib.rs +++ b/crates/migration/src/lib.rs @@ -1,6 +1,5 @@ pub use sea_orm_migration::prelude::*; -mod m20220101_000001_create_table; mod m20241003_175716_table_users; mod m20241003_175719_table_documents; @@ -10,7 +9,6 @@ pub struct Migrator; impl MigratorTrait for Migrator { fn migrations() -> Vec> { vec![ - Box::new(m20220101_000001_create_table::Migration), Box::new(m20241003_175716_table_users::Migration), Box::new(m20241003_175719_table_documents::Migration), ] diff --git a/crates/migration/src/m20220101_000001_create_table.rs b/crates/migration/src/m20220101_000001_create_table.rs deleted file mode 100644 index 7fb017b..0000000 --- a/crates/migration/src/m20220101_000001_create_table.rs +++ /dev/null @@ -1,70 +0,0 @@ -use sea_orm_migration::{prelude::*, schema::*}; - -#[derive(DeriveMigrationName)] -pub struct Migration; - -#[async_trait::async_trait] -impl MigrationTrait for Migration { - async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { - // Replace the sample below with your own migration scripts - - manager - .create_table( - Table::create() - .table(Post::Table) - .if_not_exists() - .col(pk_auto(Post::Id)) - .col(string(Post::Title)) - .col(string(Post::Text)) - .to_owned(), - ) - .await?; - - manager - .create_table( - Table::create() - .table(Zehner::Table) - .if_not_exists() - .col( - uuid(Zehner::Id) - .extra("DEFAULT gen_random_uuid()") - .primary_key(), - ) - .col(string(Zehner::Title).default("Todo")) - .col(string_null(Zehner::Text)) - .to_owned(), - ) - .await?; - - Ok(()) - } - - async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { - // Replace the sample below with your own migration scripts - - manager - .drop_table(Table::drop().table(Post::Table).to_owned()) - .await?; - - manager - .drop_table(Table::drop().table(Zehner::Table).to_owned()) - .await?; - Ok(()) - } -} - -#[derive(DeriveIden)] -enum Post { - Table, - Id, - Title, - Text, -} - -#[derive(DeriveIden)] -enum Zehner { - Table, - Id, - Title, - Text, -} diff --git a/crates/xtask/src/main.rs b/crates/xtask/src/main.rs index 93b633f..3a0cc0e 100644 --- a/crates/xtask/src/main.rs +++ b/crates/xtask/src/main.rs @@ -25,6 +25,33 @@ fn main() { .status() .expect("running backend"); } + Some(("frontend", _)) => { + process::Command::new("pnpm") + .args(["run", "dev"]) + .current_dir(workspace_dir.join("web")) + .stdout(process::Stdio::inherit()) + .stderr(process::Stdio::inherit()) + .status() + .expect("Running Frontend dev mode"); + } + // make command `cargo xtask start` run both the backend and frontend + Some(("start", _)) => { + process::Command::new("cargo") + .args(["run", "-p", "backend"]) + .current_dir(&workspace_dir) + .stdout(process::Stdio::inherit()) + .stderr(process::Stdio::inherit()) + .status() + .expect("Running Backend dev mode"); + + process::Command::new("pnpm") + .args(["run", "dev"]) + .current_dir(workspace_dir.join("web")) + .stdout(process::Stdio::inherit()) + .stderr(process::Stdio::inherit()) + .status() + .expect("Running Frontend dev mode"); + } Some(("entity", submatches)) => match submatches.subcommand() { Some(("generate", _)) => { process::Command::new("sea-orm-cli") @@ -74,6 +101,8 @@ fn cli() -> Command { .about("docusphere useful commands") .subcommand_required(true) .subcommand(Command::new("backend")) + .subcommand(Command::new("frontend")) + .subcommand(Command::new("start")) .subcommand( Command::new("entity") .subcommand_required(true)