Customise schema/object name of the MigrationLog table

dnlnlndnlnln Posts: 132
edited February 16, 2017 12:48AM in ReadyRoll
Is it possible to configure a ReadyRoll project to use a __MigrationLog table in a schema other than dbo, so that more than one application could manage and version control its database schema within a shared database?

Alternatively, is it possible to use a table named something other than __MigrationLog, to the same end?

Apologies if this is documented somewhere; I have tried to find an answer, and failed.

-Mark Davies
Daniel Nolan
Product Manager, ReadyRoll
Redgate Software
Tagged:

Comments

  • dnlnlndnlnln Posts: 132
    edited June 26, 2017 7:30AM
    It is indeed possible to deploy the [dbo].[__MigrationLog] table to an alternative schema (i.e. other than dbo).

    In order to set a custom schema name, edit your project file (.sqlproj) and add the following under the root node:
    <PropertyGroup>
    <MigrationLogSchemaName>MySchema</MigrationLogSchemaName>
    </PropertyGroup>

    The next time you deploy your project, the migration log table will be created within the specified schema (as will the related view object, [MigrationLogCurrent]).

    (Incidentally, if you're looking to split your shared database into multiple projects (i.e. so that each project only includes the objects from a specific schema), have a look at the following forum post to find out how to setup project filters:
    viewtopic.php?f=199&t=80015 )

    It is also possible to customise the table name (default: __MigrationLog) and view name (default: __MigrationLogCurrent):
    <PropertyGroup>
    <MigrationLogTableName>MyMigrationLog</MigrationLogTableName>
    <MigrationLogViewName>MyMigrationLogCurrent</MigrationLogViewName>
    </PropertyGroup>
    Daniel Nolan
    Product Manager, ReadyRoll
    Redgate Software
  • Daniel, could you check the link to the "forum post to find out how to setup project filters", it seems to be broken?
  • Tried to implement this solution, found one bug. Deployment now fails when trying to run

    EXECUTE sp_rename 'PK___MigrationLog', 'PK___MigrationLog_todrop';

    I guess this works fine when ___MigrationLog is within default (dbo) schema, but for custom schema it doesn't work. It should be

    EXECUTE sp_rename '<custom schema>.PK___MigrationLog', 'PK___MigrationLog_todrop';
  • Orm wrote: »
    Tried to implement this solution, found one bug. Deployment now fails when trying to run

    EXECUTE sp_rename 'PK___MigrationLog', 'PK___MigrationLog_todrop';
    Sorry to hear you're encountering a problem customizing the schema name. May I ask, if you have a look at the sqlproj file, what value is specified for the <ReadyRollToolsVersion> property? Is it something other than 1.12?

    The reason why I ask is that I can only reproduce the issue either when that property is either not present or set to something other than this value.
    Daniel Nolan
    Product Manager, ReadyRoll
    Redgate Software
  • Hi Daniel,

    You're totally right, this node somehow was missing from the file (I played a lot with it to set up the project). Now when it's back it works fine, thanks
  • Great to hear, thanks for confirming!

    We're in the process of resolving the T-SQL defect you spotted. I'll update this thread once its available
    Daniel Nolan
    Product Manager, ReadyRoll
    Redgate Software
Sign In or Register to comment.