Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat: Add entities #45

Merged
merged 1 commit into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,5 @@ tasks:
entities:
desc: Generate entities
cmds:
- DATABASE_URL=$RUST_ARCH__DATABASE_URL cargo run --bin migrator -- up
- sea-orm-cli generate entity -o crates/arch-db/src/entities --with-serde both -u $RUST_ARCH__DATABASE_URL
- DATABASE_URL=$RUST_ARCH__DATABASE__DATABASE_URL cargo run --bin migrator -- up
- sea-orm-cli generate entity -o crates/arch-db/src/entities --with-serde both -u $RUST_ARCH__DATABASE__DATABASE_URL
2 changes: 2 additions & 0 deletions crates/arch-db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ name = "arch_db"
path = "src/lib.rs"

[dependencies]
serde.workspace = true
serde_json.workspace = true
thiserror.workspace = true
tracing.workspace = true
tracing-log.workspace = true
Expand Down
5 changes: 5 additions & 0 deletions crates/arch-db/src/entities/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.15

pub mod prelude;

pub mod post;
18 changes: 18 additions & 0 deletions crates/arch-db/src/entities/post.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.15

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 {}
3 changes: 3 additions & 0 deletions crates/arch-db/src/entities/prelude.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.15

pub use super::post::Entity as Post;
1 change: 1 addition & 0 deletions crates/arch-db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::sync::Arc;
use sea_orm::{ConnectOptions, Database, DatabaseConnection};
pub use sea_orm_migration::prelude::*;

pub mod entities;
pub mod error;
pub use error::*;
use tracing_log::log;
Expand Down