Ignore Custom db Objects

IndyNotesGuyIndyNotesGuy Posts: 2 Bronze 1
Ok I am stumped, here is what I am trying to do:

We have a database based off another vendors schema, we take that orginial schema and add custom tables, stored procedures, functions, etc. I am trying to build a project to re-sync the core back to the orginial schema, I do not however want to drop any of the custom items we may have added.

I just want to drop any custom indexes we may have placed on the orginial database tables, and then add any new db objects the vendors database now has.

I have played with a foreach loop, looping through the differences and excluding objects which only exists in Production database, but that excludes any custom indexes we may have added.

So basically I just want to compare items that exist in both schema, what am I missing?

Thanks.

Comments

  • Thank you for your post into the forum.

    To achieve the results you are looking for you will need to perform two comparison and synchronizations.

    The first comparison and synchronization you need to use the Ignore Indexes option.
    Database db1=new Database();
                Database db2=new Database();
                 
                db1.Register(new ConnectionProperties(".", "WidgetStaging"), Options.Default);
                db2.Register(new ConnectionProperties(".", "WidgetProduction"), Options.Default);
                 
                Differences differences=db1.CompareWith(db2, Options.Default | Options.IgnoreIndexes); //Using the default options and the Ignore Indexes option
                 
                foreach (Difference difference in differences)
                {
                    Console.WriteLine("{0} {1} {2}", difference.Type.ToString(), difference.DatabaseObjectType.ToString(), difference.Name);
                }
                 
                //dispose of the objects
                db1.Dispose();
                db2.Dispose();
    

    As the Ignore Indexes will also remove any indexes you have set on your new custom tables.

    Perform another Comparison and Synchronization and only include the new custom tables with the Ignore Indexes removed. When the synchronization is run it will add the indexes you configured for the new tables.

    Many Thanks
    Eddie
    Eddie Davis
    Senior Product Support Engineer
    Redgate Software Ltd
    Email: support@red-gate.com
Sign In or Register to comment.