-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add configurable cl audits table (#94)
* Apply cl audits patch * Make cl audits configurable * Fixing missing variable. --------- Co-authored-by: juanito87 <[email protected]>
- Loading branch information
1 parent
93d02fe
commit 89aa1f0
Showing
20 changed files
with
209 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
//! SeaORM Entity. Generated by sea-orm-codegen 0.9.3 | ||
use sea_orm::entity::prelude::*; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use std::convert::From; | ||
|
||
#[derive(Copy, Clone, Default, Debug, DeriveEntity)] | ||
pub struct Entity; | ||
|
||
impl EntityName for Entity { | ||
fn table_name(&self) -> &str { | ||
"cl_audits" | ||
} | ||
} | ||
|
||
#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Serialize, Deserialize)] | ||
pub struct Model { | ||
pub id: i64, | ||
pub tree: Vec<u8>, | ||
pub node_idx: i64, | ||
pub leaf_idx: Option<i64>, | ||
pub seq: i64, | ||
pub level: i64, | ||
pub hash: Vec<u8>, | ||
pub created_at: Option<DateTime>, | ||
pub tx: String, | ||
} | ||
|
||
#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] | ||
pub enum Column { | ||
Id, | ||
Tree, | ||
NodeIdx, | ||
LeafIdx, | ||
Seq, | ||
Level, | ||
Hash, | ||
CreatedAt, | ||
Tx, | ||
} | ||
|
||
#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)] | ||
pub enum PrimaryKey { | ||
Id, | ||
} | ||
|
||
impl PrimaryKeyTrait for PrimaryKey { | ||
type ValueType = i64; | ||
fn auto_increment() -> bool { | ||
true | ||
} | ||
} | ||
|
||
#[derive(Copy, Clone, Debug, EnumIter)] | ||
pub enum Relation {} | ||
|
||
impl ColumnTrait for Column { | ||
type EntityName = Entity; | ||
fn def(&self) -> ColumnDef { | ||
match self { | ||
Self::Id => ColumnType::BigInteger.def(), | ||
Self::Tree => ColumnType::Binary.def(), | ||
Self::NodeIdx => ColumnType::BigInteger.def(), | ||
Self::LeafIdx => ColumnType::BigInteger.def().null(), | ||
Self::Seq => ColumnType::BigInteger.def(), | ||
Self::Level => ColumnType::BigInteger.def(), | ||
Self::Hash => ColumnType::Binary.def(), | ||
Self::CreatedAt => ColumnType::DateTime.def(), | ||
Self::Tx => ColumnType::String(None).def(), | ||
} | ||
} | ||
} | ||
|
||
impl RelationTrait for Relation { | ||
fn def(&self) -> RelationDef { | ||
panic!("No RelationDef") | ||
} | ||
} | ||
|
||
impl ActiveModelBehavior for ActiveModel {} | ||
|
||
impl From<crate::dao::cl_items::ActiveModel> for ActiveModel { | ||
fn from(item: crate::dao::cl_items::ActiveModel) -> Self { | ||
return ActiveModel { | ||
tree: item.tree, | ||
level: item.level, | ||
node_idx: item.node_idx, | ||
hash: item.hash, | ||
seq: item.seq, | ||
leaf_idx: item.leaf_idx, | ||
..Default::default() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
use sea_orm_migration::prelude::*; | ||
|
||
#[derive(DeriveMigrationName)] | ||
pub struct Migration; | ||
|
||
#[async_trait::async_trait] | ||
impl MigrationTrait for Migration { | ||
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { | ||
manager | ||
.create_table( | ||
Table::create() | ||
.table(ClAudits::Table) | ||
.if_not_exists() | ||
.col(ColumnDef::new(ClAudits::Id).big_integer().not_null().primary_key().auto_increment()) | ||
.col(ColumnDef::new(ClAudits::Tree).binary().not_null()) | ||
.col(ColumnDef::new(ClAudits::NodeIdx).big_integer().not_null()) | ||
.col(ColumnDef::new(ClAudits::LeafIdx).big_integer()) | ||
.col(ColumnDef::new(ClAudits::Seq).big_integer().not_null()) | ||
.col(ColumnDef::new(ClAudits::Level).big_integer().not_null()) | ||
.col(ColumnDef::new(ClAudits::Hash).binary().not_null()) | ||
.col(ColumnDef::new(ClAudits::CreatedAt).date_time().default(SimpleExpr::Keyword(Keyword::CurrentTimestamp)).not_null()) | ||
.col(ColumnDef::new(ClAudits::Tx).string().not_null()) | ||
.to_owned(), | ||
) | ||
.await | ||
} | ||
|
||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { | ||
manager | ||
.drop_table(Table::drop().table(ClAudits::Table).to_owned()) | ||
.await | ||
} | ||
} | ||
|
||
/// Learn more at https://docs.rs/sea-query#iden | ||
#[derive(Iden)] | ||
enum ClAudits { | ||
Table, | ||
Id, | ||
Tree, | ||
NodeIdx, | ||
LeafIdx, | ||
Seq, | ||
Level, | ||
Hash, | ||
CreatedAt, | ||
Tx, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.