Support Center

Working with existing databases

Last Updated: May 01, 2014 09:18PM AEST

This article has moved to a new home. For up-to-date documentation please continue reading at http://doc.ready-roll.com/display/RRSQLDOC/Working+with+existing+databases



Importing existing database objects


If you would like to import objects from an existing database, firstly connect the new project to a copy of the database and click Import (Generate Script) within the DBSync tool: a single script to create all of the imported objects will be generated and added to the project.

This operation will also insert a record in the [dbo].[__MigrationLog] table within the source database, marking the migration as deployed. This prevents the script from being re-executed against the target database.

 

 

 

Setting a baseline for an existing database

If you intend to deploy your project to an instance of your database that is different to the one you imported from (eg. you imported from the Dev environment and you now want to deploy to Production), you will need to establish a baseline in your target environment. This can be done within Visual Studio or via command line.

To set a baseline within Visual Studio, firstly connect the project to the target database and open the imported object script for editing. Click Mark as Deployed to prevent the script from being re-executed on the target.

 

Set a baseline using the Command Prompt/Continuous Integration

You can also set a baseline for your existing Production database at the command line using MSBuild.

When deploying your database project for the first time, specify the BaselineUptoMigrationId property with the filename of the migration script as the value, e.g.
 
  MsBuild.exe AdventureWorks.sqlproj
	/p:DBDeployOnBuild=True 
	/p:TargetServer=MYDBSERVER
        /p:BaselineUptoMigrationId=0001_Imported_Objects.sql
 
** If you would prefer to use SQL Server authentication (instead of Windows Integrated authentication), specify the /p:TargetUserName=... and /p:TargetPassword=... property arguments.

As of ReadyRoll 1.3, setting of a baseline for existing databases is mandatory. This avoids the possibility of accidentally deploying over the top of an existing schema (eg. [master] database). If a baseline is not set for an existing database, an error will be raised by the ReadyRoll build engine when creating a patch script.
readyroll.support@red-gate.com
http://assets1.desk.com/
false
readyrollsql
Loading
seconds ago
a minute ago
minutes ago
an hour ago
hours ago
a day ago
days ago
about
false
Invalid characters found
/customer/en/portal/articles/autocomplete