-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
I've taken the liberty to squash down this epic saga of a pull request. Here is its full list of commit messages for future reference: * Optionally adding `barrel` crate to diesel_migrations * Initial support for barrel migrations in diesel cli * Using the barrel `diesel` feature * Changing barrel call signature to build Migration on diesel side * Connecting barrel to diesel migration layouts * Formatting with rustfmt * Changing generated migration function signatures * Cleaning up migration process slightly * Pointing barrel to github version * Implementing requested changes in diesel_cli * Fix git repository link * Preliminarily commiting refactoring changes * Moving Migration trait to core diesel library * Adjusting the module comment formatting to let CI pass * Moving MigrationName back to migrations_internals * Adding new import to fix some Migration tests * Changing the migration generation function signature * Another clippy change * Renaming external feature flag. Changing barrel version to non-git * Changing barrel version to non-git in diesel_cli * Adjust the diesel feature flag on barrel * Re-exporting diesel::migration::* to avoid a breaking change * Cleaning up diesel_migration exports * Adjusting a few function calls into barrel to the v0.2.0 API * Re-adding more re-exports to diesel_migrations * Changing feature and type flag names in diesel_cli * Making error enums non exhaustive. Only exporting speific error types * Breaking formatting * Fixing formatting again * Touching code to make github see changes * Changing formatting back to the way it's meant to be * Handling __NonExaustive options for migration errors * Not exposing the entire mirations/error module anymore * Fixing some formatting issues * Optionally adding `barrel` crate to diesel_migrations * Initial support for barrel migrations in diesel cli * Changing barrel call signature to build Migration on diesel side * Connecting barrel to diesel migration layouts * Formatting with rustfmt * Changing generated migration function signatures * Cleaning up migration process slightly * Pointing barrel to github version * Implementing requested changes in diesel_cli * Preliminarily commiting refactoring changes * Moving Migration trait to core diesel library * Adjusting the module comment formatting to let CI pass * Moving MigrationName back to migrations_internals * Adding new import to fix some Migration tests * Changing the migration generation function signature * Another clippy change * Renaming external feature flag. Changing barrel version to non-git * Changing barrel version to non-git in diesel_cli * Adjust the diesel feature flag on barrel * Re-exporting diesel::migration::* to avoid a breaking change * Cleaning up diesel_migration exports * Adjusting a few function calls into barrel to the v0.2.0 API * Re-adding more re-exports to diesel_migrations * Changing feature and type flag names in diesel_cli * Making error enums non exhaustive. Only exporting speific error types * Breaking formatting * Fixing formatting again * Touching code to make github see changes * Changing formatting back to the way it's meant to be * Handling __NonExaustive options for migration errors * Not exposing the entire mirations/error module anymore * Fixing some formatting issues * Cleaning a bad merge artefact * Fixing a bad rebase
- Loading branch information
1 parent
dc84d30
commit fb1e61b
Showing
10 changed files
with
140 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
//! Representation of migrations | ||
mod errors; | ||
pub use self::errors::{MigrationError, RunMigrationsError}; | ||
|
||
use connection::SimpleConnection; | ||
use std::path::Path; | ||
|
||
/// Represents a migration that interacts with diesel | ||
pub trait Migration { | ||
/// Get the migration version | ||
fn version(&self) -> &str; | ||
/// Apply this migration | ||
fn run(&self, conn: &SimpleConnection) -> Result<(), RunMigrationsError>; | ||
/// Revert this migration | ||
fn revert(&self, conn: &SimpleConnection) -> Result<(), RunMigrationsError>; | ||
/// Get the migration file path | ||
fn file_path(&self) -> Option<&Path> { | ||
None | ||
} | ||
} | ||
|
||
impl Migration for Box<Migration> { | ||
fn version(&self) -> &str { | ||
(&**self).version() | ||
} | ||
|
||
fn run(&self, conn: &SimpleConnection) -> Result<(), RunMigrationsError> { | ||
(&**self).run(conn) | ||
} | ||
|
||
fn revert(&self, conn: &SimpleConnection) -> Result<(), RunMigrationsError> { | ||
(&**self).revert(conn) | ||
} | ||
fn file_path(&self) -> Option<&Path> { | ||
(&**self).file_path() | ||
} | ||
} | ||
|
||
impl<'a> Migration for &'a Migration { | ||
fn version(&self) -> &str { | ||
(&**self).version() | ||
} | ||
|
||
fn run(&self, conn: &SimpleConnection) -> Result<(), RunMigrationsError> { | ||
(&**self).run(conn) | ||
} | ||
|
||
fn revert(&self, conn: &SimpleConnection) -> Result<(), RunMigrationsError> { | ||
(&**self).revert(conn) | ||
} | ||
fn file_path(&self) -> Option<&Path> { | ||
(&**self).file_path() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters