Skip to content

Commit

Permalink
Add support of sea-orm v0.12 (#603)
Browse files Browse the repository at this point in the history
  • Loading branch information
rimrakhimov authored Sep 4, 2023
1 parent dca3405 commit 01400a4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
16 changes: 12 additions & 4 deletions libs/blockscout-service-launcher/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand All @@ -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",
]
7 changes: 5 additions & 2 deletions libs/blockscout-service-launcher/src/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@ 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")] {
use sea_orm_0_10::{ConnectOptions, ConnectionTrait, Database, DatabaseBackend, Statement};
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"
);
}
Expand Down

0 comments on commit 01400a4

Please sign in to comment.