diff --git a/examples/demo/Cargo.lock b/examples/demo/Cargo.lock index 51b6663af..20fa34764 100644 --- a/examples/demo/Cargo.lock +++ b/examples/demo/Cargo.lock @@ -2663,6 +2663,7 @@ dependencies = [ "thiserror", "tokio", "tokio-cron-scheduler", + "tokio-util", "toml", "tower 0.4.13", "tower-http", diff --git a/examples/demo/migration/src/lib.rs b/examples/demo/migration/src/lib.rs index 6db70a3c5..f7072b696 100644 --- a/examples/demo/migration/src/lib.rs +++ b/examples/demo/migration/src/lib.rs @@ -2,9 +2,7 @@ pub use sea_orm_migration::prelude::*; mod m20220101_000001_users; mod m20231103_114510_notes; - mod m20240416_071825_roles; - mod m20240416_082115_users_roles; pub struct Migrator; @@ -12,11 +10,11 @@ pub struct Migrator; impl MigratorTrait for Migrator { fn migrations() -> Vec> { vec![ - // inject-below (do not remove this comment) Box::new(m20220101_000001_users::Migration), Box::new(m20231103_114510_notes::Migration), Box::new(m20240416_071825_roles::Migration), Box::new(m20240416_082115_users_roles::Migration), + // inject-above (do not remove this comment) ] } } diff --git a/examples/demo/src/controllers/cache.rs b/examples/demo/src/controllers/cache.rs index 5edee1b8b..90c95fe4c 100644 --- a/examples/demo/src/controllers/cache.rs +++ b/examples/demo/src/controllers/cache.rs @@ -1,6 +1,7 @@ -use crate::models::users; use loco_rs::prelude::*; use serde::{Deserialize, Serialize}; + +use crate::models::users; #[derive(Serialize, Deserialize)] pub struct CacheResponse { value: Option, diff --git a/loco-gen/src/templates/migration.t b/loco-gen/src/templates/migration.t index dfc760758..04ac63ae7 100644 --- a/loco-gen/src/templates/migration.t +++ b/loco-gen/src/templates/migration.t @@ -6,7 +6,7 @@ skip_glob: "migration/src/*_{{mig_name}}.rs" message: "Migration for `{{name}}` added! You can now apply it with `$ cargo loco db migrate`." injections: - into: "migration/src/lib.rs" - after: "inject-below" + before: "inject-above" content: " Box::new({{module_name}}::Migration)," - into: "migration/src/lib.rs" before: "pub struct Migrator" diff --git a/loco-gen/src/templates/model.t b/loco-gen/src/templates/model.t index 928030269..a05aefee0 100644 --- a/loco-gen/src/templates/model.t +++ b/loco-gen/src/templates/model.t @@ -7,7 +7,7 @@ skip_glob: "migration/src/m????????_??????_{{plural_snake}}.rs" message: "Migration for `{{name}}` added! You can now apply it with `$ cargo loco db migrate`." injections: - into: "migration/src/lib.rs" - after: "inject-below" + before: "inject-above" content: " Box::new({{module_name}}::Migration)," - into: "migration/src/lib.rs" before: "pub struct Migrator" diff --git a/starters/rest-api/migration/src/lib.rs b/starters/rest-api/migration/src/lib.rs index b38460b97..a8e6b4ed2 100644 --- a/starters/rest-api/migration/src/lib.rs +++ b/starters/rest-api/migration/src/lib.rs @@ -10,8 +10,9 @@ pub struct Migrator; impl MigratorTrait for Migrator { fn migrations() -> Vec> { vec![ - // inject-below + // inject-below (do not remove this comment) Box::new(m20220101_000001_users::Migration), + // inject-above (do not remove this comment) ] } } diff --git a/starters/saas/migration/src/lib.rs b/starters/saas/migration/src/lib.rs index b38460b97..a8e6b4ed2 100644 --- a/starters/saas/migration/src/lib.rs +++ b/starters/saas/migration/src/lib.rs @@ -10,8 +10,9 @@ pub struct Migrator; impl MigratorTrait for Migrator { fn migrations() -> Vec> { vec![ - // inject-below + // inject-below (do not remove this comment) Box::new(m20220101_000001_users::Migration), + // inject-above (do not remove this comment) ] } }