sapiens / SqlFu

Fast and versatile .net core data mapper/micro-orm
Other
229 stars 50 forks source link

Migration versions: #33

Closed Maarten88 closed 10 years ago

Maarten88 commented 10 years ago

I have created a first Migration class (version 1.0.0) and it works fine. Now I need to add a migration to be able to deploy an update (version 1.1.0). As I understand, I have to change the version of my initial Migration class to 1.1.0 and update it to create the new schema, and add a second class containing the migration from 1.0.0 to 1.1.0, by setting these two values in the Migration attribute. However, my migration just does not seem to pick up the version numbers from the attribute and the migration task is never called.

I have tried to debug it, and it seems something deep inside goes wrong creating the migration class. If I reduce the migration to this:

[MigrationAttribute("1.0.0", "1.1.0")]
public class MyUpdate : AbstractMigrationTask
{
    public MyUpdate() : base()
    {
        Debug.WriteLine(this.CurrentVersion.ToString());
        Debug.WriteLine(this.NextVersion.ToString());
    }

    ...
}

It outputs:

1.0.0
1.0.0 

I think that is incorrect and the AbstractMigrationTask shoud have set NextVersion to 1.1.0. Is this a bug? Or am I doing it wrong?

sapiens commented 10 years ago

That's strange indeed. I have a test exactly for that purpose and it passes. Are you using .Net 4 or .Net 4.5?

Maarten88 commented 10 years ago

The error is in line 160: https://bitbucket.org/sapiensworks/caveman-tools/src/8bfd0af7d48ea1ee48518e345525ab756c2a1146/src/CavemanTools/SemanticVersion.cs?at=devel it should be: if (remain.Length >= 2)

sapiens commented 10 years ago

Why do you think that? Test passes for 1.1.0 value. I don't get it how "1.1.0" is transformed into "1.0.0"

Maarten88 commented 10 years ago

I don't understand how your test can pass. Using "1.1" it does work, because then the SemanticVersion has two parts and the second "1" get parsed. If I use "1.1.0" then the version has three parts and the second '1' is skipped, so minor stays at its default 0.

I am using Cavemantools 3.4.0 and SqlFu 2.3.0.

sapiens commented 10 years ago

I'll try a new test

sapiens commented 10 years ago

OK. I had the wrong test. I've added one specifically for parsing 1.1.0 and it fails. I'll fix caveman tools and do a release asap. Thank you for your help!

sapiens commented 10 years ago

Update released.

Maarten88 commented 10 years ago

tnx!