edit cli and removed old code
This commit is contained in:
parent
edcc2e7304
commit
8c6f859e9b
|
@ -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);
|
||||
}
|
|
@ -3,6 +3,4 @@
|
|||
pub mod prelude;
|
||||
|
||||
pub mod documents;
|
||||
pub mod post;
|
||||
pub mod users;
|
||||
pub mod zehner;
|
||||
|
|
|
@ -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 {}
|
|
@ -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;
|
||||
|
|
|
@ -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<String>,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
|
@ -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<Box<dyn MigrationTrait>> {
|
||||
vec![
|
||||
Box::new(m20220101_000001_create_table::Migration),
|
||||
Box::new(m20241003_175716_table_users::Migration),
|
||||
Box::new(m20241003_175719_table_documents::Migration),
|
||||
]
|
||||
|
|
|
@ -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,
|
||||
}
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue