Change Tracking on Shadow Database

dnlnlndnlnln Posts: 234 Gold 2
edited February 16, 2017 1:07AM in ReadyRoll
I keep getting an error when i tried to refresh in ReadyRollDBSync
at the step "Ensuring Shadow Database is up-to-date".
My database uses Change tracking in for its tables.

Here is the error

Change Tracking must be enabled on database '[MyDatabaseName_Administrator_SHADOW]' before it can be enabled on the table 'MyTableName'
Here the table "MyTableName" is a table that will have a change tracking enabled to,and it have a sql script generated in Migration Folder.

I'm using Visual Studio 2012 and MS-SQLServer 2012

-Ermias Tefera
Daniel Nolan
Product Manager
Redgate Software

Comments

  • Sorry to hear you’ve run into a problem there building your Shadow database.

    As unfortunately ReadyRoll doesn’t automatically script database-level properties, like whether Change Tracking is enabled, you’ll need to add this as a Pre-Deployment script action. To do so, add a new script under the projects Pre-Deployment folder, e.g.

    <<ProjectRoot>>Pre-Deployment2_Enable_ChangeTracking.sql

    And include logic to conditionally enable change tracking on the database, for example:
    IF NOT EXISTS (SELECT * FROM sys.change_tracking_databases WHERE database_id=DB_ID('$(DatabaseName)'))
    BEGIN
    PRINT 'Enabling change tracking in $(DatabaseName)...';
    ALTER DATABASE &#91;$(DatabaseName)&#93; SET CHANGE_TRACKING = ON;
    END
    GO
    
    In future, we hope to automate the scripting of such properties. I hope this helps for the moment, however.
    Daniel Nolan
    Product Manager
    Redgate Software
Sign In or Register to comment.