Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make schema changes to a mirrored database?

I have a mirrored database and I need to make some changes to it. Mainly, adding a view and some stored procedures. Now I know that if you make schema changes you are supposed to remove mirroring and the mirror database, make your changes to the principal, then backup-restore the principal and restore mirroring. Is this the case for stored procedures and views as well? Can I just make my changes to the Principal, then Failover and make my changes to the mirror as well? What are the possible issues and ramifications from doing something like this? It just seems like a very tedious task to have to do every time we want to make a small change, mainly because the database is over 10 gigs so it takes a little while to back up and restore.

like image 971
Russ Bradberry Avatar asked Aug 19 '09 17:08

Russ Bradberry


2 Answers

If you are mirroring, you should be able to apply those changes to the principal and they show up on the mirrored side. If you want there to be schema difference between the two, you can't use mirroring. Are you looking to apply schema changes on just the mirrored database or to both? If both then you don't have to do anything special.

like image 163
Anon246 Avatar answered Sep 21 '22 12:09

Anon246


Now I know that if you make schema changes you are supposed to remove mirroring and the mirror database, make your changes to the principal, then backup-restore the principal and restore mirroring

This is actually wrong. The principal and mirror database are in fact a single database that is stored in two physical locations. Any and every change that occurs in the principal, occurs also in the mirror. They are literarly identical all the time.

So any schema changes, including tables, views, procedures, functions, schemas, database principals, assemblies and so on and so forth occur on both the principal and the mirror.

The only changes that require special attentions are changes that are related to the database but don't occur in the database: Agent jobs (they are in msdb), server principals (logins), replication settings (they are all over the place in database, msdb and distributor.

like image 37
Remus Rusanu Avatar answered Sep 19 '22 12:09

Remus Rusanu