Closed seankearon closed 10 years ago
Yes migrations without a profile are still called. Essentially they are your base line migrations.
So, if that's true, how would you like tests that won't pick up your default migrations?
Sorry I don't understand. Are you asking how would you write a test that ignores the default migrations?
Yes, how do I write a test that ignores the default migrations?
Currently there isn't a way, but there are a couple of options.
2 is your easiest option, but I'd accept a pull request for 1 or 3 :)
what do you think?
Okay, thanks. I'll take a look at 3 - sounds the easiest route for tests.
The reason I'm asking is I'm working up a change that adds a bit of sugar around migrating collections at the JObject level. Looks like this:
[Migration(1, "CollectionDocumentMigration")]
public class CollectionDocumentMigration : Migration
{
public override void Down()
{
MigrateCollection("People", JoinFirstNameAndLastNameIntoName);
}
public override void Up()
{
MigrateCollection("People", SplitNameToFirstNameAndLastName);
}
private void JoinFirstNameAndLastNameIntoName(RavenJObject obj) { ... }
private void SplitNameToFirstNameAndLastName(RavenJObject obj) { ... }
}
You can see it here:
If you like it, I'll take route 2 above and send a pull request.
Looks awesome I would just reconsider the naming of it. Rather MigrateCollection how about using verbs like Alter, Update, and Delete.
So in the case above, we would have something like
Alter.Collection("People", SplitNameToFirstNameAndLastName);
or even
Alter.Collection("People", jobject => { /* some code */ });
What are your thoughts?
Sounds good. Will check in changes soon.
I'm getting a test failure in the existing tests from Can_call_up_then_down_on_migrations(): Bulk operation cancelled because the index is stale and allowStale is false. Updating the test to add WaitForIndexing(store); doesn't seem to fix it.
Are you seeing the same thing?
I'm using 2013 and I had to add a redirect for xunit as I was getting this:
System.IO.FileLoadException Could not load file or assembly 'xunit, Version=1.9.1.1600, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Err, cancel the last comment. That's gone away for some reason!
I get that when running the tests in ReSharper, but when running in NCrunch tests work fine. ReSharper's test runner is not best of bread anymore (imho).
Aha - I was in R#. Will look at NCrunch then. Thanks for the tip.
Pull sent!
Am I right that migrations with no profile are always called? Seems to be the case from Can_call_migrations_ignore_migrations_with_profile().
So, if that's true, how would you like tests that won't pick up your default migrations?