From 01400a4628d4c4a232ca07b80f0b1e83184fb5a7 Mon Sep 17 00:00:00 2001 From: Rim Rakhimov Date: Mon, 4 Sep 2023 12:36:02 +0400 Subject: [PATCH] Add support of sea-orm v0.12 (#603) --- libs/blockscout-service-launcher/Cargo.toml | 16 ++++++++++++---- libs/blockscout-service-launcher/src/database.rs | 7 +++++-- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/libs/blockscout-service-launcher/Cargo.toml b/libs/blockscout-service-launcher/Cargo.toml index 14a8bbf49..2fc1a3d64 100644 --- a/libs/blockscout-service-launcher/Cargo.toml +++ b/libs/blockscout-service-launcher/Cargo.toml @@ -35,6 +35,9 @@ sea-orm-migration-0_10 = { package = "sea-orm-migration", version = "0.10", opti sea-orm-0_11 = { package = "sea-orm", version = "0.11", optional = true } sea-orm-migration-0_11 = { package = "sea-orm-migration", version = "0.11", optional = true } +sea-orm-0_12 = { package = "sea-orm", version = "0.12.2", optional = true } +sea-orm-migration-0_12 = { package = "sea-orm-migration", version = "0.12.2", optional = true } + [features] default = ["launcher", "tracing"] launcher = [ @@ -58,20 +61,25 @@ tracing = [ ] # Cannot be used without corresponding sea-orm dependency. -# Choose any of `database-0_10`, `database-0_11` for the actual usage. +# Choose any of `database-0_12`, `database-0_11`, `database-0_10` for the actual usage. database = [ "dep:anyhow", "dep:cfg-if", "dep:tracing", "dep:url", ] -database-0_10 = [ +database-0_12 = [ "database", - "dep:sea-orm-0_10", - "dep:sea-orm-migration-0_10", + "dep:sea-orm-0_12", + "dep:sea-orm-migration-0_12", ] database-0_11 = [ "database", "dep:sea-orm-0_11", "dep:sea-orm-migration-0_11", ] +database-0_10 = [ + "database", + "dep:sea-orm-0_10", + "dep:sea-orm-migration-0_10", +] diff --git a/libs/blockscout-service-launcher/src/database.rs b/libs/blockscout-service-launcher/src/database.rs index 7c5e514ae..c1b0ee473 100644 --- a/libs/blockscout-service-launcher/src/database.rs +++ b/libs/blockscout-service-launcher/src/database.rs @@ -2,7 +2,10 @@ use anyhow::Context; use std::str::FromStr; cfg_if::cfg_if! { - if #[cfg(feature = "database-0_11")] { + if #[cfg(feature = "database-0_12")] { + use sea_orm_0_12::{ConnectOptions, ConnectionTrait, Database, DatabaseBackend, Statement}; + use sea_orm_migration_0_12::MigratorTrait; + } else if #[cfg(feature = "database-0_11")] { use sea_orm_0_11::{ConnectOptions, ConnectionTrait, Database, DatabaseBackend, Statement}; use sea_orm_migration_0_11::MigratorTrait; } else if #[cfg(feature = "database-0_10")] { @@ -10,7 +13,7 @@ cfg_if::cfg_if! { use sea_orm_migration_0_10::MigratorTrait; } else { compile_error!( - "one of the features ['database-0_11', 'database-0_10'] \ + "one of the features ['database-0_12', 'database-0_11', 'database-0_10'] \ must be enabled" ); }