Skip to content

Commit

Permalink
feat: Add entities (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
szinn authored Aug 14, 2024
1 parent 42ba37b commit 99dd2b8
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 2 deletions.
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

0 comments on commit 99dd2b8

Please sign in to comment.