Team City plugin drops database

A SQL Server Management Studio add-in to source control your database in Subversion or Team Foundation Server.

Team City plugin drops database

Postby nforss » Tue Oct 16, 2012 7:01 am


I've been trying to get SQL Source Control to work together with Team City using the plugin provided by Red Gate. My problem is that even though the plugin configuration explicitly states that the runner wont create the database for me, it first drops the db and then tries doing exactly that. (The sql server user account does not have permission to create a new db.)

The error message in the Team City log looks like this

Code: Select all
[09:44:47]Step 12/17: Build database from source control (Red Gate (SQL Server))
[09:44:47][Step 12/17] Starting: C:\\TeamCity\\buildAgent\\plugins\\RedGateSQLServer\\assets\\sqlCI.exe /scriptsFolder=Database /databaseServer=SERVER /databaseUserName=USERNAME /databasePassword=PASSWORD /databaseName=staging /packageRepository=null /packageId=staging /packageVersion=243
[09:44:47][Step 12/17] in directory: C:\\TeamCity\\buildAgent\\work\\394b341d423ece2d
[09:44:48][Step 12/17]
[09:44:48][Step 12/17] Unhandled Exception: System.Data.SqlClient.SqlException: CREATE DATABASE permission denied in database 'master'.
[09:44:48][Step 12/17] at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
[09:44:48][Step 12/17] at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
[09:44:48][Step 12/17] at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
[09:44:48][Step 12/17] at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout)
[09:44:48][Step 12/17] at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite)
[09:44:48][Step 12/17] at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
[09:44:48][Step 12/17] at ##.#PCSc(SqlConnection #Gjoc, #WrPb )
[09:44:48][Step 12/17] at #WMRc.#WrPb.#8vSc()
[09:44:48][Step 12/17] at #JMRc.#NNd.#yMSc(#IMRc #gnSc, #LQRc #AfSc, #TMRc #vhSc, #lO3 #qBSc, #MHTc #RHTc, #MHTc #SuUc)
[09:44:48][Step 12/17] at ##.#2MRc(String[] #ead)
[09:44:53][Step 12/17] Process exited with code 255
[09:44:53][Step 12/17] Step Build database from source control (Red Gate (SQL Server)) failed

What is going on here? If I don't create the database, the plugin complains about it not being found. The configuration is so very simple I really don't see a way I could be misunderstanding it.

Any help would be appreciated!

Posts: 2
Joined: Tue Oct 16, 2012 6:22 am

Postby dmweyek » Wed Oct 17, 2012 6:12 pm

I'm also dealing with an issue with the TeamCity plugin. I don't want the plugin to drop the database. There doesn't seem to be an option for this in the plugin.

In my case, the plugin drops the DB has some strange sync failure and leaves the DB empty.

Another interesting note. The sync fails but the build is reported as successful.

Code: Select all
[10:43:03][Generating creation script] Error: Synchronization of 'Scripts.state' and 'xxxx.xInventory' failed:
Posts: 14
Joined: Tue May 15, 2012 11:53 pm

Postby dmweyek » Thu Oct 25, 2012 9:16 pm

After looking at some of the artifacts posted by the build tools I Can see in the Deploy.ps1 power shell file that there is switch for mode.

and else.

Does anyone know what I can change to affect these options. In my case, I want to do upgrades and not createnew. Is this not the right forum for these issues?
Posts: 14
Joined: Tue May 15, 2012 11:53 pm

Postby hnorton » Sat Oct 27, 2012 5:20 am

I am also seeing the same issue using TeamCity 7.1 and the latest Red Gate plugin. Again, it looks like the cause is something missing in the deploy.ps1 file. It looks like it depends on the $mode variable being set to either "createnew" or "update". But nowhere in the plugin do I see the ability to set that.
Posts: 1
Joined: Sat Oct 27, 2012 4:59 am

Postby David Atkinson » Sat Oct 27, 2012 9:15 am

The TeamCity plugin currently drops and recreates a database in order to run tests, and generate and validate creation and upgrade scripts. It needs to rebuild the database to verify that the creation script works and to create a clean state for the unit tests.

The next version of the plugin will also provide an option to specify a database that is simply kept up to date incrementally with the latest changes. If you could hold out for the next plugin then I think it will work for you.

Another option is to not use the plugin for this scenario and call in a separate command line build step:

sqlcompare.exe /scripts1:<yourscriptsfolder> /s2:<yourserver> /db2:<yourdatbase> /sync
David Atkinson
Posts: 1137
Joined: Mon Dec 05, 2005 3:54 pm
Location: Twitter: @dtabase

Postby dmweyek » Thu Nov 08, 2012 12:59 am


Is this the proper forum for the Team City plugin. I have some other errors I'm seeing but I'm not sure where to post them.


Posts: 14
Joined: Tue May 15, 2012 11:53 pm

Postby David Atkinson » Thu Nov 08, 2012 1:04 am

Please create a new topic in this forum please. We'll eventually create a dedicated forum for CI and automated build processes.
David Atkinson
Posts: 1137
Joined: Mon Dec 05, 2005 3:54 pm
Location: Twitter: @dtabase

Return to SQL Source Control Previous Versions

Who is online

Users browsing this forum: No registered users and 0 guests