Data Migration issue

Topics: Core, Troubleshooting
Jul 24, 2015 at 6:28 AM
Orchard.Data.Migration.DataMigrationManager - (null) - An unexpected error occurred while applying migration on Orchard.Taxonomies from version 3.

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Data.SqlClient.SqlException: The operation failed because an index or statistics with name 'MY_IDX_Path' already exists on table ''MY_Orchard_Taxonomies_TermPartRecord'.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource
1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at Orchard.Data.Migration.Interpreters.DefaultDataMigrationInterpreter.RunPendingStatements() in c:\code\Hitachi\src\Orchard\Data\Migration\Interpreters\DefaultDataMigrationInterpreter.cs:line 336
at Orchard.Data.Migration.Interpreters.DefaultDataMigrationInterpreter.Visit(AlterTableCommand command) in c:\code\Hitachi\src\Orchard\Data\Migration\Interpreters\DefaultDataMigrationInterpreter.cs:line 148
at Orchard.Data.Migration.Interpreters.AbstractDataMigrationInterpreter.Visit(ISchemaBuilderCommand command) in c:\code\Hitachi\src\Orchard\Data\Migration\Interpreters\AbstractDataMigrationInterpreter.cs:line 17
at Orchard.Data.Migration.Schema.SchemaBuilder.Run(ISchemaBuilderCommand command) in c:\code\Hitachi\src\Orchard\Data\Migration\Schema\SchemaBuilder.cs:line 66
at Orchard.Data.Migration.Schema.SchemaBuilder.AlterTable(String name, Action`1 table) in c:\code\Hitachi\src\Orchard\Data\Migration\Schema\SchemaBuilder.cs:line 42
at Orchard.Taxonomies.Migrations.UpdateFrom3()
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at Orchard.Data.Migration.DataMigrationManager.Update(String feature) in c:\code\Hitachi\src\Orchard\Data\Migration\DataMigrationManager.cs:line 123

MyMigration class (
public int Create()
    {
        SchemaBuilder.CreateTable("TaxonomyPartRecord", table => table
            .ContentPartRecord()
            .Column<string>("TermTypeName", column => column.WithLength(255))
            .Column<bool>("IsInternal")
        );

      SchemaBuilder.CreateTable("TermPartRecord", table => table
            .ContentPartRecord()
            .Column<string>("Path", column => column.WithLength(255))
            .Column<int>("TaxonomyId")
            .Column<int>("Count")
            .Column<int>("Weight")
            .Column<bool>("Selectable")
        ).AlterTable("TermPartRecord", table => table
            .CreateIndex("IDX_Path", "Path")
        );

        SchemaBuilder.CreateTable("TermContentItem", table => table
            .Column<int>("Id", column => column.PrimaryKey().Identity())
            .Column<string>("Field", column => column.WithLength(50))
            .Column<int>("TermRecord_id")
            .Column<int>("TermsPartRecord_id")
        );

        ContentDefinitionManager.AlterTypeDefinition("Taxonomy", cfg => cfg
            .WithPart("TaxonomyPart")
            .WithPart("CommonPart")
            .WithPart("TitlePart")
            .WithPart("AutoroutePart", builder => builder
            .WithSetting("AutorouteSettings.AllowCustomPattern", "true")
            .WithSetting("AutorouteSettings.AutomaticAdjustmentOnEdit", "false")
            .WithSetting("AutorouteSettings.PatternDefinitions", "[{Name:'Title', Pattern: '{Content.Slug}', Description: 'my-taxonomy'}]")
            .WithSetting("AutorouteSettings.DefaultPatternIndex", "0"))
        );

        SchemaBuilder.CreateTable("TermsPartRecord", table => table
            .ContentPartRecord()
        );

        ContentDefinitionManager.AlterTypeDefinition("TaxonomyNavigationMenuItem",
           cfg => cfg
               .WithPart("TaxonomyNavigationPart")
               .WithPart("MenuPart")
               .WithPart("CommonPart")
               .DisplayedAs("Taxonomy Link")
               .WithSetting("Description", "Injects menu items from a Taxonomy")
               .WithSetting("Stereotype", "MenuItem")
           );

        return 3;
    }
namespace Orchard.Taxonomies
select * from [dbo].[Orchard_Framework_DataMigrationRecord] where DataMigrationClass like '%Tax%'
Result:
Id DataMigrationClass Version
26 Orchard.Taxonomies.Migrations 3

Any help would be appreciated to fix this bug.