Kentico CMS 7.0 Developer's Guide

Modifying structure of a replicated DB

Modifying structure of a replicated DB

Previous topic Next topic Mail us feedback on this topic!  

Modifying structure of a replicated DB

Previous topic Next topic JavaScript is required for the print function Mail us feedback on this topic!  

It is possible to make some changes to the DB structure even without disestablishing the existing replication.


Adding forms, custom tables or document types


Forms, custom tables and document types can be created even when database replication is established. You only need to follow the steps below to


1. Create the form, custom table or document type from within the publisher's Kentico CMS user interface.


2. Open SQL Server Management Studio. In Object Explorer, expand the Replication -> Local publications node, right-click your publication and choose Properties from the context menu.




3. In Publication Properties, select Articles from the right menu. You will see a tree of database tables which are synchronized to the subscribers. You can verify that the new table created in step 1 is missing, i.e. it is not synchronized. Right-click Tables (the root of the tree) and click Publish All Tables.




4. In case that a new table is found, you are displayed with a confirmation window where you need to confirm that you really want to add the table (article) to the publication. Click Yes. The table will be added and you should be able to find it in the tree. Click OK.




5. Now back in Object Explorer, right-click the publication again and choose Reinitialize All Subscriptions from the context menu.




6. A dialog window will be raised, telling you that all subscriptions need to be reinitialized from a snapshot the next time its Merge Agent runs. For the changes to be reflected, you need to reinitialize the subscriptions from a snapshot of the new database structure, i.e. from a snapshot which has been taken after steps 1-4 have been performed.


If you haven't created the snapshot since you finished step 4, choose Use a new snapshot and Generate the new snapshot now. If you already have the snapshot, choose Use the current snapshot.


Click Mark For Reinitialization. Next time the subscriptions' Merge Agent runs, the subscriptions will be reinitialized with the new database structure.




Field changes in system tables


It is also possible to make changes to the fields of System tables without disestablishing an existing replication. In this case, you need to replace all views on the subscription databases with views from the modified publisher database.


The easiest way to do this is to generate a DROP And CREATE script on the publication database and run it on the subscription databases.


1. Click F7 to open Object Explorer Details view and select the Views folder of the publication database.


2. Select all listed views, right-click and select Script View as -> DROP And CREATE To -> New Query Editor Window from the context menu.


3. Execute the generated script on the subscription databases.




Field changes in document types


Changes to document type fields can also be made without disestablishing an existing replication. The solution in this case is almost identical to the solution for system tables (described above). The only difference is that you don't need to DROP And CREATE all views, but only the view related to the particular document type.