-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding barrel
feature
#1573
Adding barrel
feature
#1573
Conversation
diesel_cli/src/cli.rs
Outdated
.long("type") | ||
.short("t") | ||
.takes_value(true) | ||
.help("Specify the migration type."), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add .possible_values(&["sql", "barrel"])
and .default_value("sql")
?
diesel_cli/src/cli.rs
Outdated
@@ -51,6 +51,13 @@ pub fn build_cli() -> App<'static, 'static> { | |||
for most use cases.", | |||
) | |||
.takes_value(true), | |||
) | |||
.arg( | |||
Arg::with_name("type") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Arg names should be uppercase by convention.
diesel_cli/src/main.rs
Outdated
down.write_all(b"-- This file should undo anything in `up.sql`") | ||
.unwrap(); | ||
match migration_type { | ||
Some("barrel") => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be #[cfg]
d.
diesel_cli/src/main.rs
Outdated
barrel_migr.write(b"/// Handle down migrations \n").unwrap(); | ||
barrel_migr | ||
.write(b"fn down(migr: &mut Migration) {} \n") | ||
.unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of this code should live in Barrel, not Diesel.
diesel_cli/src/main.rs
Outdated
.unwrap(); | ||
} | ||
_ => { | ||
let up_path = migration_dir.join("up.sql"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we pull this out into a function?
@@ -49,6 +58,39 @@ pub fn migration_from(path: PathBuf) -> Result<Box<Migration>, MigrationError> { | |||
} | |||
} | |||
|
|||
#[cfg(feature = "barrel")] | |||
struct BarrelMigration(PathBuf, String, String, String); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we just move the migration trait from diesel_migrations
into diesel
so this code can live in Barrel?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good start, but there's more restructuring to be done. Given that we don't maintain Barrel, I want to have as little Barrel specific code in Diesel as possible.
CI is failing. |
Yea, there is a problem with the code I don't know how to solve. I messaged you on gitter about it. Also, looking at what's failing, it seems to be fine on one of the nightly branches. |
Oh whoops! Sorry!
…On Fri, Feb 23, 2018, 5:19 PM Katharina ***@***.***> wrote:
Yea, there is a problem with the code I don't know how to solve. I
messaged you on gitter about it
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1573 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABdWK9hPJnh0r9DzpXAhM84gbtuHQMWWks5tX1WSgaJpZM4SPfcY>
.
|
diesel/src/migration/mod.rs
Outdated
/// A migration name | ||
#[allow(missing_debug_implementations)] | ||
#[derive(Clone, Copy)] | ||
pub struct MigrationName<'a> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did this need to move?
diesel/src/migration/mod.rs
Outdated
@@ -19,3 +20,67 @@ pub trait Migration { | |||
None | |||
} | |||
} | |||
|
|||
/// A migration name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we document what this actually does rather than just repeating the name of the type?
diesel/src/migration/mod.rs
Outdated
#[allow(missing_debug_implementations)] | ||
#[derive(Clone, Copy)] | ||
pub struct MigrationName<'a> { | ||
/// Wraps around a migration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we provide more information than just repeating the type?
diesel/src/migration/mod.rs
Outdated
pub migration: &'a Migration, | ||
} | ||
|
||
/// Get the name of a migration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we provide more information than just repeating the function/argument names? Maybe at least a usage example?
That's a fair point, I moved the |
Ping @sgrif it builds now! 🎉 😄 |
I'm at a conference, but one of the other committers can take care of
merging. I'd like to see this squashed down.
…On Mon, Apr 16, 2018 at 8:22 PM Katharina ***@***.***> wrote:
Ping @sgrif <https://github.com/sgrif> it builds now! 🎉 😄
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1573 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABdWKwQjRoJoyX2lLe8NTqaS5hQonqyCks5tpTW6gaJpZM4SPfcY>
.
|
This is the initial version of integrating
barrel
into diesel. A few things are still not optimal and I'd like to get some feedback regarding that.There are some barrel specific functions and structs in the
migrations_internal
module which are only compiled when using barrel. I would love to keep those parts in the barrel crate but can't because of cyclic dependencies. Is there a different way to solve this? If so, how?Currently (for testing) the
barrel
feature is always enabled on diesel. How would I addfeatures = [ "barrel"]
to themigration_internals
crate, depending on the external flag? Is there a more elegant way of doing this?Should the code added to
diesel_cli
be conditionally added with abarrel
feature flag too?Additionally the barrel dependency currently points to
git
which should be changed oncebarrel 0.2
is released