From 13a042b8728a0cc484272dde6934f7364b842546 Mon Sep 17 00:00:00 2001 From: Kirill Fedoseev Date: Mon, 11 Dec 2023 12:11:35 +0400 Subject: [PATCH 1/3] chore: bump sea-orm in blockscout-db to 0.12 --- libs/blockscout-db/entity/Cargo.toml | 2 +- .../entity/src/address_coin_balances.rs | 8 +++-- .../entity/src/address_coin_balances_daily.rs | 8 +++-- .../src/address_current_token_balances.rs | 4 ++- .../blockscout-db/entity/src/address_names.rs | 4 ++- .../entity/src/address_token_balances.rs | 4 ++- libs/blockscout-db/entity/src/addresses.rs | 9 ++++-- .../entity/src/administrators.rs | 2 +- .../blockscout-db/entity/src/block_rewards.rs | 14 +++++++-- .../src/block_second_degree_relations.rs | 14 +++++++-- libs/blockscout-db/entity/src/blocks.rs | 16 ++++++++-- .../entity/src/contract_methods.rs | 3 +- .../src/contract_verification_status.rs | 3 +- .../entity/src/decompiled_smart_contracts.rs | 3 +- .../entity/src/emission_rewards.rs | 4 +-- .../entity/src/event_notifications.rs | 2 +- .../entity/src/internal_transactions.rs | 16 ++++++++-- .../entity/src/last_fetched_counters.rs | 2 +- libs/blockscout-db/entity/src/lib.rs | 3 +- libs/blockscout-db/entity/src/logs.rs | 16 ++++++++-- .../entity/src/market_history.rs | 2 +- .../entity/src/pending_block_operations.rs | 8 +++-- libs/blockscout-db/entity/src/prelude.rs | 2 +- .../entity/src/schema_migrations.rs | 2 +- .../entity/src/sea_orm_active_enums.rs | 3 -- .../entity/src/smart_contracts.rs | 4 ++- .../src/smart_contracts_additional_sources.rs | 3 +- .../entity/src/token_instances.rs | 9 ++++-- .../entity/src/token_transfers.rs | 17 +++++++++-- libs/blockscout-db/entity/src/tokens.rs | 8 +++-- .../entity/src/transaction_forks.rs | 9 ++++-- .../entity/src/transaction_stats.rs | 2 +- libs/blockscout-db/entity/src/transactions.rs | 29 ++++++++++++++----- .../blockscout-db/entity/src/user_contacts.rs | 6 ++-- libs/blockscout-db/entity/src/users.rs | 6 ++-- libs/blockscout-db/migration/Cargo.toml | 4 +-- 36 files changed, 181 insertions(+), 70 deletions(-) delete mode 100644 libs/blockscout-db/entity/src/sea_orm_active_enums.rs diff --git a/libs/blockscout-db/entity/Cargo.toml b/libs/blockscout-db/entity/Cargo.toml index 9e6a1099a..6bff390e2 100644 --- a/libs/blockscout-db/entity/Cargo.toml +++ b/libs/blockscout-db/entity/Cargo.toml @@ -9,4 +9,4 @@ name = "entity" path = "src/lib.rs" [dependencies] -sea-orm = { version = "0.10", features = [ "sqlx-postgres", "runtime-tokio-rustls", "macros", "postgres-array" ] } +sea-orm = { version = "0.12", features = [ "sqlx-postgres", "runtime-tokio-rustls", "macros", "postgres-array" ] } diff --git a/libs/blockscout-db/entity/src/address_coin_balances.rs b/libs/blockscout-db/entity/src/address_coin_balances.rs index 5dd4e4d07..90db46d4b 100644 --- a/libs/blockscout-db/entity/src/address_coin_balances.rs +++ b/libs/blockscout-db/entity/src/address_coin_balances.rs @@ -1,11 +1,15 @@ -//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.4 +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.6 use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "address_coin_balances")] pub struct Model { - #[sea_orm(primary_key, auto_increment = false)] + #[sea_orm( + primary_key, + auto_increment = false, + column_type = "Binary(BlobSize::Blob(None))" + )] pub address_hash: Vec, #[sea_orm(primary_key, auto_increment = false)] pub block_number: i64, diff --git a/libs/blockscout-db/entity/src/address_coin_balances_daily.rs b/libs/blockscout-db/entity/src/address_coin_balances_daily.rs index 19ca34703..a60d1e92c 100644 --- a/libs/blockscout-db/entity/src/address_coin_balances_daily.rs +++ b/libs/blockscout-db/entity/src/address_coin_balances_daily.rs @@ -1,11 +1,15 @@ -//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.4 +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.6 use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "address_coin_balances_daily")] pub struct Model { - #[sea_orm(primary_key, auto_increment = false)] + #[sea_orm( + primary_key, + auto_increment = false, + column_type = "Binary(BlobSize::Blob(None))" + )] pub address_hash: Vec, #[sea_orm(primary_key, auto_increment = false)] pub day: Date, diff --git a/libs/blockscout-db/entity/src/address_current_token_balances.rs b/libs/blockscout-db/entity/src/address_current_token_balances.rs index 7742bf525..34380ca2d 100644 --- a/libs/blockscout-db/entity/src/address_current_token_balances.rs +++ b/libs/blockscout-db/entity/src/address_current_token_balances.rs @@ -1,4 +1,4 @@ -//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.4 +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.6 use sea_orm::entity::prelude::*; @@ -7,8 +7,10 @@ use sea_orm::entity::prelude::*; pub struct Model { #[sea_orm(primary_key)] pub id: i64, + #[sea_orm(column_type = "Binary(BlobSize::Blob(None))")] pub address_hash: Vec, pub block_number: i64, + #[sea_orm(column_type = "Binary(BlobSize::Blob(None))")] pub token_contract_address_hash: Vec, pub value: Option, pub value_fetched_at: Option, diff --git a/libs/blockscout-db/entity/src/address_names.rs b/libs/blockscout-db/entity/src/address_names.rs index bf7ab8d07..efa314ba7 100644 --- a/libs/blockscout-db/entity/src/address_names.rs +++ b/libs/blockscout-db/entity/src/address_names.rs @@ -1,15 +1,17 @@ -//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.4 +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.6 use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "address_names")] pub struct Model { + #[sea_orm(column_type = "Binary(BlobSize::Blob(None))")] pub address_hash: Vec, pub name: String, pub primary: bool, pub inserted_at: DateTime, pub updated_at: DateTime, + #[sea_orm(column_type = "JsonBinary", nullable)] pub metadata: Option, #[sea_orm(primary_key)] pub id: i32, diff --git a/libs/blockscout-db/entity/src/address_token_balances.rs b/libs/blockscout-db/entity/src/address_token_balances.rs index e757a3a5a..ec9bc0a1d 100644 --- a/libs/blockscout-db/entity/src/address_token_balances.rs +++ b/libs/blockscout-db/entity/src/address_token_balances.rs @@ -1,4 +1,4 @@ -//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.4 +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.6 use sea_orm::entity::prelude::*; @@ -7,8 +7,10 @@ use sea_orm::entity::prelude::*; pub struct Model { #[sea_orm(primary_key)] pub id: i64, + #[sea_orm(column_type = "Binary(BlobSize::Blob(None))")] pub address_hash: Vec, pub block_number: i64, + #[sea_orm(column_type = "Binary(BlobSize::Blob(None))")] pub token_contract_address_hash: Vec, pub value: Option, pub value_fetched_at: Option, diff --git a/libs/blockscout-db/entity/src/addresses.rs b/libs/blockscout-db/entity/src/addresses.rs index 0fc41fd1c..3a6601559 100644 --- a/libs/blockscout-db/entity/src/addresses.rs +++ b/libs/blockscout-db/entity/src/addresses.rs @@ -1,4 +1,4 @@ -//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.4 +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.6 use sea_orm::entity::prelude::*; @@ -8,8 +8,13 @@ pub struct Model { #[sea_orm(column_type = "Decimal(Some((100, 0)))", nullable)] pub fetched_coin_balance: Option, pub fetched_coin_balance_block_number: Option, - #[sea_orm(primary_key, auto_increment = false)] + #[sea_orm( + primary_key, + auto_increment = false, + column_type = "Binary(BlobSize::Blob(None))" + )] pub hash: Vec, + #[sea_orm(column_type = "Binary(BlobSize::Blob(None))", nullable)] pub contract_code: Option>, pub inserted_at: DateTime, pub updated_at: DateTime, diff --git a/libs/blockscout-db/entity/src/administrators.rs b/libs/blockscout-db/entity/src/administrators.rs index 7bf0b4cb1..234ae8996 100644 --- a/libs/blockscout-db/entity/src/administrators.rs +++ b/libs/blockscout-db/entity/src/administrators.rs @@ -1,4 +1,4 @@ -//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.4 +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.6 use sea_orm::entity::prelude::*; diff --git a/libs/blockscout-db/entity/src/block_rewards.rs b/libs/blockscout-db/entity/src/block_rewards.rs index bd445b9fb..e3580026e 100644 --- a/libs/blockscout-db/entity/src/block_rewards.rs +++ b/libs/blockscout-db/entity/src/block_rewards.rs @@ -1,15 +1,23 @@ -//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.4 +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.6 use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "block_rewards")] pub struct Model { - #[sea_orm(primary_key, auto_increment = false)] + #[sea_orm( + primary_key, + auto_increment = false, + column_type = "Binary(BlobSize::Blob(None))" + )] pub address_hash: Vec, #[sea_orm(primary_key, auto_increment = false)] pub address_type: String, - #[sea_orm(primary_key, auto_increment = false)] + #[sea_orm( + primary_key, + auto_increment = false, + column_type = "Binary(BlobSize::Blob(None))" + )] pub block_hash: Vec, #[sea_orm(column_type = "Decimal(Some((100, 0)))", nullable)] pub reward: Option, diff --git a/libs/blockscout-db/entity/src/block_second_degree_relations.rs b/libs/blockscout-db/entity/src/block_second_degree_relations.rs index 26e56ecaf..8a9b70dab 100644 --- a/libs/blockscout-db/entity/src/block_second_degree_relations.rs +++ b/libs/blockscout-db/entity/src/block_second_degree_relations.rs @@ -1,13 +1,21 @@ -//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.4 +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.6 use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "block_second_degree_relations")] pub struct Model { - #[sea_orm(primary_key, auto_increment = false)] + #[sea_orm( + primary_key, + auto_increment = false, + column_type = "Binary(BlobSize::Blob(None))" + )] pub nephew_hash: Vec, - #[sea_orm(primary_key, auto_increment = false)] + #[sea_orm( + primary_key, + auto_increment = false, + column_type = "Binary(BlobSize::Blob(None))" + )] pub uncle_hash: Vec, pub uncle_fetched_at: Option, pub index: Option, diff --git a/libs/blockscout-db/entity/src/blocks.rs b/libs/blockscout-db/entity/src/blocks.rs index 25f8f54b5..d642ac9f1 100644 --- a/libs/blockscout-db/entity/src/blocks.rs +++ b/libs/blockscout-db/entity/src/blocks.rs @@ -1,4 +1,4 @@ -//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.4 +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.6 use sea_orm::entity::prelude::*; @@ -12,11 +12,18 @@ pub struct Model { pub gas_limit: Decimal, #[sea_orm(column_type = "Decimal(Some((100, 0)))")] pub gas_used: Decimal, - #[sea_orm(primary_key, auto_increment = false)] + #[sea_orm( + primary_key, + auto_increment = false, + column_type = "Binary(BlobSize::Blob(None))" + )] pub hash: Vec, + #[sea_orm(column_type = "Binary(BlobSize::Blob(None))")] pub miner_hash: Vec, + #[sea_orm(column_type = "Binary(BlobSize::Blob(None))")] pub nonce: Vec, pub number: i64, + #[sea_orm(column_type = "Binary(BlobSize::Blob(None))")] pub parent_hash: Vec, pub size: Option, pub timestamp: DateTime, @@ -108,7 +115,10 @@ impl Related for Entity { impl Related for Entity { fn to() -> RelationDef { - Relation::Transactions.def() + super::transaction_forks::Relation::Transactions.def() + } + fn via() -> Option { + Some(super::transaction_forks::Relation::Blocks.def().rev()) } } diff --git a/libs/blockscout-db/entity/src/contract_methods.rs b/libs/blockscout-db/entity/src/contract_methods.rs index 37f131270..a1b7f98b9 100644 --- a/libs/blockscout-db/entity/src/contract_methods.rs +++ b/libs/blockscout-db/entity/src/contract_methods.rs @@ -1,4 +1,4 @@ -//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.4 +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.6 use sea_orm::entity::prelude::*; @@ -8,6 +8,7 @@ pub struct Model { #[sea_orm(primary_key)] pub id: i64, pub identifier: i32, + #[sea_orm(column_type = "JsonBinary")] pub abi: Json, pub r#type: String, pub inserted_at: DateTime, diff --git a/libs/blockscout-db/entity/src/contract_verification_status.rs b/libs/blockscout-db/entity/src/contract_verification_status.rs index a51a4d6a4..b7b35771a 100644 --- a/libs/blockscout-db/entity/src/contract_verification_status.rs +++ b/libs/blockscout-db/entity/src/contract_verification_status.rs @@ -1,4 +1,4 @@ -//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.4 +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.6 use sea_orm::entity::prelude::*; @@ -8,6 +8,7 @@ pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub uid: String, pub status: i16, + #[sea_orm(column_type = "Binary(BlobSize::Blob(None))")] pub address_hash: Vec, pub inserted_at: DateTime, pub updated_at: DateTime, diff --git a/libs/blockscout-db/entity/src/decompiled_smart_contracts.rs b/libs/blockscout-db/entity/src/decompiled_smart_contracts.rs index 7cfafe0b0..7c19df29d 100644 --- a/libs/blockscout-db/entity/src/decompiled_smart_contracts.rs +++ b/libs/blockscout-db/entity/src/decompiled_smart_contracts.rs @@ -1,4 +1,4 @@ -//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.4 +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.6 use sea_orm::entity::prelude::*; @@ -10,6 +10,7 @@ pub struct Model { pub decompiler_version: String, #[sea_orm(column_type = "Text")] pub decompiled_source_code: String, + #[sea_orm(column_type = "Binary(BlobSize::Blob(None))")] pub address_hash: Vec, pub inserted_at: DateTime, pub updated_at: DateTime, diff --git a/libs/blockscout-db/entity/src/emission_rewards.rs b/libs/blockscout-db/entity/src/emission_rewards.rs index 28cc1fef3..8245b6970 100644 --- a/libs/blockscout-db/entity/src/emission_rewards.rs +++ b/libs/blockscout-db/entity/src/emission_rewards.rs @@ -1,4 +1,4 @@ -//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.4 +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.6 use sea_orm::entity::prelude::*; @@ -8,7 +8,7 @@ pub struct Model { #[sea_orm( primary_key, auto_increment = false, - column_type = "Custom(\"int8range\".to_owned())" + column_type = "custom(\"int8range\")" )] pub block_range: String, pub reward: Option, diff --git a/libs/blockscout-db/entity/src/event_notifications.rs b/libs/blockscout-db/entity/src/event_notifications.rs index 29f9e6a6c..7ea40c0da 100644 --- a/libs/blockscout-db/entity/src/event_notifications.rs +++ b/libs/blockscout-db/entity/src/event_notifications.rs @@ -1,4 +1,4 @@ -//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.4 +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.6 use sea_orm::entity::prelude::*; diff --git a/libs/blockscout-db/entity/src/internal_transactions.rs b/libs/blockscout-db/entity/src/internal_transactions.rs index 43a067246..9e1ce18cd 100644 --- a/libs/blockscout-db/entity/src/internal_transactions.rs +++ b/libs/blockscout-db/entity/src/internal_transactions.rs @@ -1,4 +1,4 @@ -//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.4 +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.6 use sea_orm::entity::prelude::*; @@ -6,6 +6,7 @@ use sea_orm::entity::prelude::*; #[sea_orm(table_name = "internal_transactions")] pub struct Model { pub call_type: Option, + #[sea_orm(column_type = "Binary(BlobSize::Blob(None))", nullable)] pub created_contract_code: Option>, pub error: Option, #[sea_orm(column_type = "Decimal(Some((100, 0)))", nullable)] @@ -13,8 +14,11 @@ pub struct Model { #[sea_orm(column_type = "Decimal(Some((100, 0)))", nullable)] pub gas_used: Option, pub index: i32, + #[sea_orm(column_type = "Binary(BlobSize::Blob(None))", nullable)] pub init: Option>, + #[sea_orm(column_type = "Binary(BlobSize::Blob(None))", nullable)] pub input: Option>, + #[sea_orm(column_type = "Binary(BlobSize::Blob(None))", nullable)] pub output: Option>, pub trace_address: Vec, pub r#type: String, @@ -22,13 +26,21 @@ pub struct Model { pub value: Decimal, pub inserted_at: DateTime, pub updated_at: DateTime, + #[sea_orm(column_type = "Binary(BlobSize::Blob(None))", nullable)] pub created_contract_address_hash: Option>, + #[sea_orm(column_type = "Binary(BlobSize::Blob(None))", nullable)] pub from_address_hash: Option>, + #[sea_orm(column_type = "Binary(BlobSize::Blob(None))", nullable)] pub to_address_hash: Option>, + #[sea_orm(column_type = "Binary(BlobSize::Blob(None))")] pub transaction_hash: Vec, pub block_number: Option, pub transaction_index: Option, - #[sea_orm(primary_key, auto_increment = false)] + #[sea_orm( + primary_key, + auto_increment = false, + column_type = "Binary(BlobSize::Blob(None))" + )] pub block_hash: Vec, #[sea_orm(primary_key, auto_increment = false)] pub block_index: i32, diff --git a/libs/blockscout-db/entity/src/last_fetched_counters.rs b/libs/blockscout-db/entity/src/last_fetched_counters.rs index 967824352..f8647f368 100644 --- a/libs/blockscout-db/entity/src/last_fetched_counters.rs +++ b/libs/blockscout-db/entity/src/last_fetched_counters.rs @@ -1,4 +1,4 @@ -//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.4 +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.6 use sea_orm::entity::prelude::*; diff --git a/libs/blockscout-db/entity/src/lib.rs b/libs/blockscout-db/entity/src/lib.rs index c0205e4aa..ac6174600 100644 --- a/libs/blockscout-db/entity/src/lib.rs +++ b/libs/blockscout-db/entity/src/lib.rs @@ -1,4 +1,4 @@ -//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.4 +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.6 pub mod prelude; @@ -23,7 +23,6 @@ pub mod logs; pub mod market_history; pub mod pending_block_operations; pub mod schema_migrations; -pub mod sea_orm_active_enums; pub mod smart_contracts; pub mod smart_contracts_additional_sources; pub mod token_instances; diff --git a/libs/blockscout-db/entity/src/logs.rs b/libs/blockscout-db/entity/src/logs.rs index 16ec4fb67..1532ba7c7 100644 --- a/libs/blockscout-db/entity/src/logs.rs +++ b/libs/blockscout-db/entity/src/logs.rs @@ -1,10 +1,11 @@ -//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.4 +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.6 use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "logs")] pub struct Model { + #[sea_orm(column_type = "Binary(BlobSize::Blob(None))")] pub data: Vec, #[sea_orm(primary_key, auto_increment = false)] pub index: i32, @@ -15,10 +16,19 @@ pub struct Model { pub fourth_topic: Option, pub inserted_at: DateTime, pub updated_at: DateTime, + #[sea_orm(column_type = "Binary(BlobSize::Blob(None))", nullable)] pub address_hash: Option>, - #[sea_orm(primary_key, auto_increment = false)] + #[sea_orm( + primary_key, + auto_increment = false, + column_type = "Binary(BlobSize::Blob(None))" + )] pub transaction_hash: Vec, - #[sea_orm(primary_key, auto_increment = false)] + #[sea_orm( + primary_key, + auto_increment = false, + column_type = "Binary(BlobSize::Blob(None))" + )] pub block_hash: Vec, pub block_number: Option, } diff --git a/libs/blockscout-db/entity/src/market_history.rs b/libs/blockscout-db/entity/src/market_history.rs index 78fc0416b..23fbbdaab 100644 --- a/libs/blockscout-db/entity/src/market_history.rs +++ b/libs/blockscout-db/entity/src/market_history.rs @@ -1,4 +1,4 @@ -//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.4 +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.6 use sea_orm::entity::prelude::*; diff --git a/libs/blockscout-db/entity/src/pending_block_operations.rs b/libs/blockscout-db/entity/src/pending_block_operations.rs index e41b93f30..477674c01 100644 --- a/libs/blockscout-db/entity/src/pending_block_operations.rs +++ b/libs/blockscout-db/entity/src/pending_block_operations.rs @@ -1,11 +1,15 @@ -//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.4 +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.6 use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "pending_block_operations")] pub struct Model { - #[sea_orm(primary_key, auto_increment = false)] + #[sea_orm( + primary_key, + auto_increment = false, + column_type = "Binary(BlobSize::Blob(None))" + )] pub block_hash: Vec, pub inserted_at: DateTime, pub updated_at: DateTime, diff --git a/libs/blockscout-db/entity/src/prelude.rs b/libs/blockscout-db/entity/src/prelude.rs index 1f7446ac0..0d42411da 100644 --- a/libs/blockscout-db/entity/src/prelude.rs +++ b/libs/blockscout-db/entity/src/prelude.rs @@ -1,4 +1,4 @@ -//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.4 +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.6 pub use super::{ address_coin_balances::Entity as AddressCoinBalances, diff --git a/libs/blockscout-db/entity/src/schema_migrations.rs b/libs/blockscout-db/entity/src/schema_migrations.rs index 9e92fd798..96f19575a 100644 --- a/libs/blockscout-db/entity/src/schema_migrations.rs +++ b/libs/blockscout-db/entity/src/schema_migrations.rs @@ -1,4 +1,4 @@ -//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.4 +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.6 use sea_orm::entity::prelude::*; diff --git a/libs/blockscout-db/entity/src/sea_orm_active_enums.rs b/libs/blockscout-db/entity/src/sea_orm_active_enums.rs deleted file mode 100644 index a9468bf8d..000000000 --- a/libs/blockscout-db/entity/src/sea_orm_active_enums.rs +++ /dev/null @@ -1,3 +0,0 @@ -//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.4 - -pub type Citext = String; diff --git a/libs/blockscout-db/entity/src/smart_contracts.rs b/libs/blockscout-db/entity/src/smart_contracts.rs index 927371c88..424b52203 100644 --- a/libs/blockscout-db/entity/src/smart_contracts.rs +++ b/libs/blockscout-db/entity/src/smart_contracts.rs @@ -1,4 +1,4 @@ -//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.4 +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.6 use sea_orm::entity::prelude::*; @@ -12,7 +12,9 @@ pub struct Model { pub optimization: bool, #[sea_orm(column_type = "Text")] pub contract_source_code: String, + #[sea_orm(column_type = "JsonBinary")] pub abi: Json, + #[sea_orm(column_type = "Binary(BlobSize::Blob(None))")] pub address_hash: Vec, pub inserted_at: DateTime, pub updated_at: DateTime, diff --git a/libs/blockscout-db/entity/src/smart_contracts_additional_sources.rs b/libs/blockscout-db/entity/src/smart_contracts_additional_sources.rs index 6568576a5..a078ec361 100644 --- a/libs/blockscout-db/entity/src/smart_contracts_additional_sources.rs +++ b/libs/blockscout-db/entity/src/smart_contracts_additional_sources.rs @@ -1,4 +1,4 @@ -//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.4 +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.6 use sea_orm::entity::prelude::*; @@ -10,6 +10,7 @@ pub struct Model { pub file_name: String, #[sea_orm(column_type = "Text")] pub contract_source_code: String, + #[sea_orm(column_type = "Binary(BlobSize::Blob(None))")] pub address_hash: Vec, pub inserted_at: DateTime, pub updated_at: DateTime, diff --git a/libs/blockscout-db/entity/src/token_instances.rs b/libs/blockscout-db/entity/src/token_instances.rs index a42d9f51c..d93441d0f 100644 --- a/libs/blockscout-db/entity/src/token_instances.rs +++ b/libs/blockscout-db/entity/src/token_instances.rs @@ -1,4 +1,4 @@ -//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.4 +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.6 use sea_orm::entity::prelude::*; @@ -11,8 +11,13 @@ pub struct Model { column_type = "Decimal(Some((78, 0)))" )] pub token_id: Decimal, - #[sea_orm(primary_key, auto_increment = false)] + #[sea_orm( + primary_key, + auto_increment = false, + column_type = "Binary(BlobSize::Blob(None))" + )] pub token_contract_address_hash: Vec, + #[sea_orm(column_type = "JsonBinary", nullable)] pub metadata: Option, pub inserted_at: DateTime, pub updated_at: DateTime, diff --git a/libs/blockscout-db/entity/src/token_transfers.rs b/libs/blockscout-db/entity/src/token_transfers.rs index 913713395..50e455677 100644 --- a/libs/blockscout-db/entity/src/token_transfers.rs +++ b/libs/blockscout-db/entity/src/token_transfers.rs @@ -1,24 +1,35 @@ -//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.4 +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.6 use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "token_transfers")] pub struct Model { - #[sea_orm(primary_key, auto_increment = false)] + #[sea_orm( + primary_key, + auto_increment = false, + column_type = "Binary(BlobSize::Blob(None))" + )] pub transaction_hash: Vec, #[sea_orm(primary_key, auto_increment = false)] pub log_index: i32, + #[sea_orm(column_type = "Binary(BlobSize::Blob(None))")] pub from_address_hash: Vec, + #[sea_orm(column_type = "Binary(BlobSize::Blob(None))")] pub to_address_hash: Vec, pub amount: Option, #[sea_orm(column_type = "Decimal(Some((78, 0)))", nullable)] pub token_id: Option, + #[sea_orm(column_type = "Binary(BlobSize::Blob(None))")] pub token_contract_address_hash: Vec, pub inserted_at: DateTime, pub updated_at: DateTime, pub block_number: Option, - #[sea_orm(primary_key, auto_increment = false)] + #[sea_orm( + primary_key, + auto_increment = false, + column_type = "Binary(BlobSize::Blob(None))" + )] pub block_hash: Vec, pub amounts: Option>, pub token_ids: Option>, diff --git a/libs/blockscout-db/entity/src/tokens.rs b/libs/blockscout-db/entity/src/tokens.rs index 0f1310817..429cb224b 100644 --- a/libs/blockscout-db/entity/src/tokens.rs +++ b/libs/blockscout-db/entity/src/tokens.rs @@ -1,4 +1,4 @@ -//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.4 +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.6 use sea_orm::entity::prelude::*; @@ -12,7 +12,11 @@ pub struct Model { pub decimals: Option, pub r#type: String, pub cataloged: Option, - #[sea_orm(primary_key, auto_increment = false)] + #[sea_orm( + primary_key, + auto_increment = false, + column_type = "Binary(BlobSize::Blob(None))" + )] pub contract_address_hash: Vec, pub inserted_at: DateTime, pub updated_at: DateTime, diff --git a/libs/blockscout-db/entity/src/transaction_forks.rs b/libs/blockscout-db/entity/src/transaction_forks.rs index d252d6602..511791c12 100644 --- a/libs/blockscout-db/entity/src/transaction_forks.rs +++ b/libs/blockscout-db/entity/src/transaction_forks.rs @@ -1,14 +1,19 @@ -//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.4 +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.6 use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "transaction_forks")] pub struct Model { + #[sea_orm(column_type = "Binary(BlobSize::Blob(None))")] pub hash: Vec, #[sea_orm(primary_key, auto_increment = false)] pub index: i32, - #[sea_orm(primary_key, auto_increment = false)] + #[sea_orm( + primary_key, + auto_increment = false, + column_type = "Binary(BlobSize::Blob(None))" + )] pub uncle_hash: Vec, pub inserted_at: DateTime, pub updated_at: DateTime, diff --git a/libs/blockscout-db/entity/src/transaction_stats.rs b/libs/blockscout-db/entity/src/transaction_stats.rs index 3ef5b3aad..fd302956b 100644 --- a/libs/blockscout-db/entity/src/transaction_stats.rs +++ b/libs/blockscout-db/entity/src/transaction_stats.rs @@ -1,4 +1,4 @@ -//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.4 +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.6 use sea_orm::entity::prelude::*; diff --git a/libs/blockscout-db/entity/src/transactions.rs b/libs/blockscout-db/entity/src/transactions.rs index bd18013ae..15c16411c 100644 --- a/libs/blockscout-db/entity/src/transactions.rs +++ b/libs/blockscout-db/entity/src/transactions.rs @@ -1,4 +1,4 @@ -//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.4 +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.6 use sea_orm::entity::prelude::*; @@ -14,9 +14,14 @@ pub struct Model { pub gas_price: Decimal, #[sea_orm(column_type = "Decimal(Some((100, 0)))", nullable)] pub gas_used: Option, - #[sea_orm(primary_key, auto_increment = false)] + #[sea_orm( + primary_key, + auto_increment = false, + column_type = "Binary(BlobSize::Blob(None))" + )] pub hash: Vec, pub index: Option, + #[sea_orm(column_type = "Binary(BlobSize::Blob(None))")] pub input: Vec, pub nonce: i32, #[sea_orm(column_type = "Decimal(Some((100, 0)))")] @@ -30,13 +35,18 @@ pub struct Model { pub value: Decimal, pub inserted_at: DateTime, pub updated_at: DateTime, + #[sea_orm(column_type = "Binary(BlobSize::Blob(None))", nullable)] pub block_hash: Option>, pub block_number: Option, + #[sea_orm(column_type = "Binary(BlobSize::Blob(None))")] pub from_address_hash: Vec, + #[sea_orm(column_type = "Binary(BlobSize::Blob(None))", nullable)] pub to_address_hash: Option>, + #[sea_orm(column_type = "Binary(BlobSize::Blob(None))", nullable)] pub created_contract_address_hash: Option>, pub created_contract_code_indexed_at: Option, pub earliest_processing_start: Option, + #[sea_orm(column_type = "Binary(BlobSize::Blob(None))", nullable)] pub old_block_hash: Option>, #[sea_orm(column_type = "Text", nullable)] pub revert_reason: Option, @@ -92,12 +102,6 @@ pub enum Relation { TransactionForks, } -impl Related for Entity { - fn to() -> RelationDef { - Relation::Blocks.def() - } -} - impl Related for Entity { fn to() -> RelationDef { Relation::InternalTransactions.def() @@ -122,4 +126,13 @@ impl Related for Entity { } } +impl Related for Entity { + fn to() -> RelationDef { + super::transaction_forks::Relation::Blocks.def() + } + fn via() -> Option { + Some(super::transaction_forks::Relation::Transactions.def().rev()) + } +} + impl ActiveModelBehavior for ActiveModel {} diff --git a/libs/blockscout-db/entity/src/user_contacts.rs b/libs/blockscout-db/entity/src/user_contacts.rs index aede0b9d2..2781b9d3d 100644 --- a/libs/blockscout-db/entity/src/user_contacts.rs +++ b/libs/blockscout-db/entity/src/user_contacts.rs @@ -1,6 +1,5 @@ -//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.4 +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.6 -use super::sea_orm_active_enums::Citext; use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] @@ -8,7 +7,8 @@ use sea_orm::entity::prelude::*; pub struct Model { #[sea_orm(primary_key)] pub id: i64, - pub email: Citext, + #[sea_orm(column_type = "custom(\"citext\")")] + pub email: String, pub user_id: i64, pub primary: Option, pub verified: Option, diff --git a/libs/blockscout-db/entity/src/users.rs b/libs/blockscout-db/entity/src/users.rs index 29d354c70..1b0fd7e36 100644 --- a/libs/blockscout-db/entity/src/users.rs +++ b/libs/blockscout-db/entity/src/users.rs @@ -1,6 +1,5 @@ -//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.4 +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.6 -use super::sea_orm_active_enums::Citext; use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] @@ -8,7 +7,8 @@ use sea_orm::entity::prelude::*; pub struct Model { #[sea_orm(primary_key)] pub id: i64, - pub username: Citext, + #[sea_orm(column_type = "custom(\"citext\")")] + pub username: String, pub password_hash: String, pub inserted_at: DateTime, pub updated_at: DateTime, diff --git a/libs/blockscout-db/migration/Cargo.toml b/libs/blockscout-db/migration/Cargo.toml index 1b1e0495e..23760bcad 100644 --- a/libs/blockscout-db/migration/Cargo.toml +++ b/libs/blockscout-db/migration/Cargo.toml @@ -12,11 +12,11 @@ path = "src/lib.rs" async-std = { version = "^1", features = ["attributes", "tokio1"] } [dependencies.sea-orm-migration] -version = "^0.10.0" +version = "0.12" features = [ # Enable at least one `ASYNC_RUNTIME` and `DATABASE_DRIVER` feature if you want to run migration via CLI. # View the list of supported features at https://www.sea-ql.org/SeaORM/docs/install-and-config/database-and-async-runtime. # e.g. "runtime-tokio-rustls", # `ASYNC_RUNTIME` feature "sqlx-postgres", # `DATABASE_DRIVER` feature -] \ No newline at end of file +] From 3d61ff4096bd9ca85ce1f3cec59f728ca2ac9dee Mon Sep 17 00:00:00 2001 From: Kirill Fedoseev Date: Mon, 11 Dec 2023 12:17:13 +0400 Subject: [PATCH 2/3] chore: freeze blockscout-db in stats --- stats/Cargo.lock | 6 +++--- stats/stats/Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/stats/Cargo.lock b/stats/Cargo.lock index 98fd53dc3..02fb44a24 100644 --- a/stats/Cargo.lock +++ b/stats/Cargo.lock @@ -607,7 +607,7 @@ dependencies = [ [[package]] name = "blockscout-db" version = "4.1.8" -source = "git+https://github.com/blockscout/blockscout-rs#e4409334a8d050821a665e8e67f242472eac4c6e" +source = "git+https://github.com/blockscout/blockscout-rs?rev=e440933#e4409334a8d050821a665e8e67f242472eac4c6e" dependencies = [ "blockscout-db-entity", "blockscout-db-migration", @@ -616,7 +616,7 @@ dependencies = [ [[package]] name = "blockscout-db-entity" version = "4.1.8" -source = "git+https://github.com/blockscout/blockscout-rs#e4409334a8d050821a665e8e67f242472eac4c6e" +source = "git+https://github.com/blockscout/blockscout-rs?rev=e440933#e4409334a8d050821a665e8e67f242472eac4c6e" dependencies = [ "sea-orm", ] @@ -624,7 +624,7 @@ dependencies = [ [[package]] name = "blockscout-db-migration" version = "4.1.8" -source = "git+https://github.com/blockscout/blockscout-rs#e4409334a8d050821a665e8e67f242472eac4c6e" +source = "git+https://github.com/blockscout/blockscout-rs?rev=e440933#e4409334a8d050821a665e8e67f242472eac4c6e" dependencies = [ "async-std", "sea-orm-migration", diff --git a/stats/stats/Cargo.toml b/stats/stats/Cargo.toml index 70e61b7c5..406e767a0 100644 --- a/stats/stats/Cargo.toml +++ b/stats/stats/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" [dependencies] entity = { path = "./entity" } -blockscout-db = { git = "https://github.com/blockscout/blockscout-rs" } +blockscout-db = { git = "https://github.com/blockscout/blockscout-rs", rev = "e440933" } sea-orm = { version = "0.10", features = [ "sqlx-postgres", "runtime-tokio-rustls", From ccf7bf5053e78b897380c60bd8b8783d9764a475 Mon Sep 17 00:00:00 2001 From: Kirill Fedoseev Date: Mon, 11 Dec 2023 12:29:18 +0400 Subject: [PATCH 3/3] chore: lint --- libs/blockscout-db/migration/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/blockscout-db/migration/src/lib.rs b/libs/blockscout-db/migration/src/lib.rs index ed0224eae..75148e4b9 100644 --- a/libs/blockscout-db/migration/src/lib.rs +++ b/libs/blockscout-db/migration/src/lib.rs @@ -1,5 +1,5 @@ pub use sea_orm_migration::prelude::*; -use sea_orm_migration::sea_orm::{ConnectionTrait, Statement, TransactionTrait}; +use sea_orm_migration::sea_orm::{Statement, TransactionTrait}; mod m20220101_000001_create_table;