Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion sea-orm-migration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ sea-schema = { version = "0.17.0-rc", default-features = false, features = [
"writer",
"probe",
] }
time = { version = "0.3.36", default-features = false, optional = true }
tracing = { version = "0.1", default-features = false, features = ["log"] }
tracing-subscriber = { version = "0.3.17", default-features = false, features = [
"env-filter",
Expand Down Expand Up @@ -89,7 +90,7 @@ with-chrono = ["sea-orm/with-chrono"]
with-ipnetwork = ["sea-orm/with-ipnetwork"]
with-json = ["sea-orm/with-json"]
with-rust_decimal = ["sea-orm/with-rust_decimal"]
with-time = ["sea-orm/with-time"]
with-time = ["time", "sea-orm/with-time"]
with-uuid = ["sea-orm/with-uuid"]

# This allows us to develop using an overridden version of sea-query
Expand Down
13 changes: 10 additions & 3 deletions sea-orm-migration/src/migrator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ use std::collections::HashSet;
use std::fmt::Display;
use std::future::Future;
use std::pin::Pin;
#[cfg(not(feature = "time"))]
use std::time::SystemTime;
#[cfg(feature = "time")]
use time::OffsetDateTime;
use tracing::info;

use sea_orm::sea_query::{
Expand Down Expand Up @@ -468,12 +471,16 @@ async fn exec_up_with(
info!("Applying migration '{}'", migration.name());
migration.up(manager).await?;
info!("Migration '{}' has been applied", migration.name());
let now = SystemTime::now()
#[cfg(not(feature = "time"))]
let applied_at = SystemTime::now()
.duration_since(SystemTime::UNIX_EPOCH)
.expect("SystemTime before UNIX EPOCH!");
.expect("SystemTime before UNIX EPOCH!")
.as_secs() as i64;
#[cfg(feature = "time")]
let applied_at = OffsetDateTime::now_utc().unix_timestamp();
seaql_migrations::Entity::insert(seaql_migrations::ActiveModel {
version: ActiveValue::Set(migration.name().to_owned()),
applied_at: ActiveValue::Set(now.as_secs() as i64),
applied_at: ActiveValue::Set(applied_at),
})
.table_name(migration_table_name.clone())
.exec(db)
Expand Down