Migrations Not Updating Version Number Correctly

Topics: Customizing Orchard, Writing modules
Sep 7, 2011 at 11:56 AM
Edited Sep 8, 2011 at 11:41 AM

If I have a migration file with multiple methods that are to be executed then all the migrations are run, but the version number in Orchard_Framework_DataMigrationRecord is not correct.

For example, if I have the following methods in my Migration file, when I update both columns will be added, but the version number in the Orchard_Framework_DataMigrationRecord table will be 5 rather than 6.

 

 

	public int UpdateFrom4() {

            SchemaBuilder.AlterTable("RecentBlogPostsPartRecord",
                table => table
                    .AddColumn("Test2", DbType.DateTime)
                );

            return 5;
        }

        public int UpdateFrom5()
        {

            SchemaBuilder.AlterTable("RecentBlogPostsPartRecord",
                table => table
                    .AddColumn("Test3", DbType.DateTime)
                );

            return 6;
        }

 

I have debugged the code in the DataMigrationManager class and the dataMigrationRecord.Version property seems to be set to the correct value, but when the SQL update statement is executed it has the wrong version number. I'm finding it difficult to see what is going wrong because it just seems to be in the NHibenate code.

 

This looks to me to be a bug. Anyone else seeing this?

Sep 8, 2011 at 4:48 PM

I suspect this is something to do with the NHibernate versioning. I added an additional property to the DataMigrationRecord class and associated table and that property seems to work fine.

Coordinator
Sep 8, 2011 at 5:09 PM

I think you are right. A column named "Version" has a pre-defined meaning for NHibernate wrt to versioning. I would open a bug about this (nice find!)

    public class DataMigrationRecord {
        public virtual int Id { get; set; }
        public virtual string DataMigrationClass { get; set; }
        public virtual int Version { get; set; }
    }

 


Sep 8, 2011 at 5:26 PM

Okay, thanks. Bug opened here http://orchard.codeplex.com/workitem/18116