I've worked myself into a corner, and I'm not sure how to handle this.
I have a large set of databases with generally the same structure. Each database has a list of ID columns that are currently
int that i need to convert to
bigint. Presently, i'm creating scripts by hand to remove all of the constraints, indexes, and keys before modifying the columns to bigint and putting all of those objects back.
The problem I'm running into with slightly modifying the same script over and over is that I wind up losing objects or creating new objects along the way, which i'm not supposed to do. There's a few catches to this:
1) Some indexes are used in custom logic on a database, so they'll be present in some databases but not all. So, losing indexes is very bad.
2) Disk space is a major concern, so I need to make sure I don't include additional indexes (which apparently cost this?)
3) There's a lot of logic that depends on keys and constraints working, so I can't risk losing any of these.
Is there a way to create scripts for this, so I don't have to do these comparisons by hand and risk losing or adding objects that shouldn't be there?