Skip to content

Commit

Permalink
Accept source path as argument to adding migration (#7)
Browse files Browse the repository at this point in the history
Adds a `source` parameter to the `add` method instead of trying to
auto-determine the migrations path. Also bumps the minor version to
`0.2.0` as a result.
  • Loading branch information
akrantz01 authored Sep 7, 2023
1 parent 0718d4b commit 3151d21
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "migrator"
description = "A simple library for managing database migrations"
version = "0.1.3"
version = "0.2.0"
license = "MIT"
homepage = "https://github.com/TheHackerApp/migrator"
repository = "https://github.com/TheHackerApp/migrator.git"
Expand Down
11 changes: 3 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,10 @@ use error::Result;

/// Create a new migration
#[instrument]
pub fn add(name: &str) -> Result<()> {
let migrations = {
let base = Path::new(env!("CARGO_MANIFEST_DIR"));
base.join("migrations")
};

pub fn add(source: &Path, name: &str) -> Result<()> {
let name = name.replace(' ', "_");
create_file(&migrations, &name, MigrationType::ReversibleUp)?;
create_file(&migrations, &name, MigrationType::ReversibleDown)?;
create_file(source, &name, MigrationType::ReversibleUp)?;
create_file(source, &name, MigrationType::ReversibleDown)?;

Ok(())
}
Expand Down

0 comments on commit 3151d21

Please # to comment.