Team City plugin drops database

nforssnforss Posts: 3
Hi,

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
[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!

/Nicklas

Comments

  • 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.
    [10:43:03][Generating creation script] Error: Synchronization of 'Scripts.state' and 'xxxx.xInventory' failed:
    
  • 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.

    createnew
    upgrade
    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?
  • 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.
  • 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
    Product Manager
    Redgate Software
  • David,

    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.

    Thanks,

    Doug
  • Please create a new topic in this forum please. We'll eventually create a dedicated forum for CI and automated build processes.
    David Atkinson
    Product Manager
    Redgate Software
Sign In or Register to comment.