-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(backfiller): add cl_audit_v2 to ingestion for recording every se…
…q for a tree
- Loading branch information
Showing
26 changed files
with
420 additions
and
156 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
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,74 @@ | ||
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.5 | ||
use super::sea_orm_active_enums::BubblegumInstruction; | ||
use sea_orm::entity::prelude::*; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Copy, Clone, Default, Debug, DeriveEntity)] | ||
pub struct Entity; | ||
|
||
impl EntityName for Entity { | ||
fn table_name(&self) -> &str { | ||
"cl_audits_v2" | ||
} | ||
} | ||
|
||
#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq, Serialize, Deserialize)] | ||
pub struct Model { | ||
pub id: i64, | ||
pub tree: Vec<u8>, | ||
pub leaf_idx: i64, | ||
pub seq: i64, | ||
pub created_at: DateTime, | ||
pub tx: Vec<u8>, | ||
pub instruction: BubblegumInstruction, | ||
} | ||
|
||
#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] | ||
pub enum Column { | ||
Id, | ||
Tree, | ||
LeafIdx, | ||
Seq, | ||
CreatedAt, | ||
Tx, | ||
Instruction, | ||
} | ||
|
||
#[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::LeafIdx => ColumnType::BigInteger.def(), | ||
Self::Seq => ColumnType::BigInteger.def(), | ||
Self::CreatedAt => ColumnType::DateTime.def(), | ||
Self::Tx => ColumnType::Binary.def(), | ||
Self::Instruction => BubblegumInstruction::db_type(), | ||
} | ||
} | ||
} | ||
|
||
impl RelationTrait for Relation { | ||
fn def(&self) -> RelationDef { | ||
panic!("No RelationDef") | ||
} | ||
} | ||
|
||
impl ActiveModelBehavior for ActiveModel {} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
use enum_iterator::{all, Sequence}; | ||
use sea_orm_migration::prelude::{sea_query::extension::postgres::Type, *}; | ||
use sea_orm_migration::sea_orm::{ConnectionTrait, DatabaseBackend, Statement}; | ||
|
||
#[derive(DeriveMigrationName)] | ||
pub struct Migration; | ||
|
||
#[async_trait::async_trait] | ||
impl MigrationTrait for Migration { | ||
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { | ||
let conn = manager.get_connection(); | ||
|
||
manager | ||
.create_type( | ||
Type::create() | ||
.as_enum(BubblegumInstruction::Table) | ||
.values(all::<BubblegumInstruction>().map(|e| e).collect::<Vec<_>>()) | ||
.to_owned(), | ||
) | ||
.await?; | ||
|
||
manager | ||
.create_table( | ||
Table::create() | ||
.table(ClAuditsV2::Table) | ||
.if_not_exists() | ||
.col( | ||
ColumnDef::new(ClAuditsV2::Id) | ||
.big_integer() | ||
.not_null() | ||
.auto_increment() | ||
.primary_key(), | ||
) | ||
.col(ColumnDef::new(ClAuditsV2::Tree).binary().not_null()) | ||
.col(ColumnDef::new(ClAuditsV2::LeafIdx).big_integer().not_null()) | ||
.col(ColumnDef::new(ClAuditsV2::Seq).big_integer().not_null()) | ||
.col( | ||
ColumnDef::new(ClAuditsV2::CreatedAt) | ||
.date_time() | ||
.default(SimpleExpr::Keyword(Keyword::CurrentTimestamp)) | ||
.not_null(), | ||
) | ||
.col(ColumnDef::new(ClAuditsV2::Tx).binary().not_null()) | ||
.col( | ||
ColumnDef::new(ClAuditsV2::Instruction) | ||
.custom(BubblegumInstruction::Table) | ||
.not_null() | ||
) | ||
.to_owned(), | ||
) | ||
.await?; | ||
|
||
conn.execute(Statement::from_string( | ||
DatabaseBackend::Postgres, | ||
"ALTER TABLE cl_audits_v2 ADD CONSTRAINT unique_tree_leafidx_seq UNIQUE (tree, leaf_idx, seq);".to_string(), | ||
)) | ||
.await?; | ||
|
||
Ok(()) | ||
} | ||
|
||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { | ||
manager | ||
.drop_type( | ||
Type::drop() | ||
.if_exists() | ||
.name(BubblegumInstruction::Table) | ||
.to_owned(), | ||
) | ||
.await?; | ||
|
||
manager | ||
.drop_table(Table::drop().table(ClAuditsV2::Table).to_owned()) | ||
.await?; | ||
Ok(()) | ||
} | ||
} | ||
|
||
/// Learn more at https://docs.rs/sea-query#iden | ||
#[derive(Iden)] | ||
enum ClAuditsV2 { | ||
Table, | ||
Id, | ||
Tree, | ||
LeafIdx, | ||
Seq, | ||
CreatedAt, | ||
Tx, | ||
Instruction, | ||
} | ||
|
||
#[derive(Iden, Debug, PartialEq, Sequence)] | ||
enum BubblegumInstruction { | ||
Table, | ||
Unknown, | ||
MintV1, | ||
Redeem, | ||
CancelRedeem, | ||
Transfer, | ||
Delegate, | ||
DecompressV1, | ||
Compress, | ||
Burn, | ||
VerifyCreator, | ||
UnverifyCreator, | ||
VerifyCollection, | ||
UnverifyCollection, | ||
SetAndVerifyCollection, | ||
MintToCollectionV1, | ||
CreateTree, | ||
} |
62 changes: 0 additions & 62 deletions
62
migration/src/m20231208_103949_create_tree_transactions_table.rs
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.