1

I added the Deploy ReadyRoll Database Package task in VSTS release definition for deploying the ReadyRoll SQL Server Database Project using Migration Approach.

I followed this link to create ReadRoll SQL Server Database Project in VS2017.

I configured the build definition using Hosted VS2017 Agent in VSTS like this below figure.

enter image description here

And also configured the configured release definition using Hosted VS2017 Agent in VSTS like this below figure.

enter image description here

After that, I created release in Hosted VS2017 then I faced the issue like this below figure enter image description here

But here I used the Azure SQL Server and Database with SQL Server Authentication.

Can you please tell me how to resolve this issue as soon as possible?

Pradeep
  • 5,101
  • 14
  • 68
  • 140

1 Answers1

3

Adding PowerShell task before Deploy ReayRoll Database Package:

Type: Inline Script

Inline Script:

$sqlcmd = "C:\Program Files\Microsoft SQL Server\110\Tools\Binn";
Write-Host "##vso[task.setvariable variable=PATH;]${env:PATH};${sqlcmd}";
starian chen-MSFT
  • 33,174
  • 2
  • 29
  • 53
  • Even I added Powershell script before Deploy Ready Roll Database package, still I am getting the same issue. – Pradeep Sep 11 '17 at 04:55
  • @pradeep Add System.Debug variable and set it to true, then start a release and share the logs on the OneDrive. – starian chen-MSFT Sep 11 '17 at 05:20
  • This is the links for logs https://1drv.ms/u/s!At-JUB9_wu9CvgIZKIUc4g8dw4Zc – Pradeep Sep 11 '17 at 05:27
  • @pradeep Based on the error, there is pre-deployment script to create KZWU-RES-DB-02 database, but it is already existing, so it fails, using different database instead or delete the existing database. – starian chen-MSFT Sep 11 '17 at 06:04
  • @pradeep What's the detail error message in the log? You can share it again. – starian chen-MSFT Sep 12 '17 at 01:22
  • currently I used the Local SQL database connection details to apply local database migrations sucessfully. But whenever I used azure SQL database connection details to apply local database migrations it gives the error like "sqlcmd.exe exited with a non-zero exit code." – Pradeep Sep 12 '17 at 17:35
  • @pradeep try removing `Pre-Deployment\01_Create_Database.sql` from the project (that script should contain conditions to prevent it from trying to create a DB that already exists, but that doesn't seem to be working). Also please ensure that you are using ReadyRoll 1.14.8 or later. – Dan Nolan Sep 12 '17 at 23:49
  • @pradeep Share the log files on the OneDrive. – starian chen-MSFT Sep 13 '17 at 01:29
  • This is the links for logs https://1drv.ms/u/s!At-JUB9_wu9CvhPoCMyGJuOvyNCt – Pradeep Sep 13 '17 at 06:07
  • @pradeep Based on the log, the error still is Database 'KZWU-RES-DB-03' already exists, remove Pre-Deployment\01_Create_Database.sql and try again. – starian chen-MSFT Sep 13 '17 at 06:43
  • I already tried by removing 01_Create_Database.sql file but still I got same issues. this is the link of logs https://1drv.ms/u/s!At-JUB9_wu9CvW6dtNl_Gjqzl0pQ – Pradeep Sep 13 '17 at 07:19
  • @pradeep The error is USE statement is not supported to switch between databases, could you share a simple project on the OneDrive? – starian chen-MSFT Sep 13 '17 at 09:07
  • This is my simple project https://1drv.ms/f/s!At-JUB9_wu9CvhbBKUh4cmG2jh6m – Pradeep Sep 13 '17 at 09:12
  • 1
    @pradeep Right click project in VS=> Properties=>Project Settings=>Choose Microsoft Azure SQL Database V12 in Target platform, then check in changes and build, release. – starian chen-MSFT Sep 13 '17 at 09:47
  • Thanks @starain, you saved my time. now its working with out any issues – Pradeep Sep 13 '17 at 10:06