Open bryangeiger opened 1 year ago
I imagine you have a need for the configuration to be stored in a config file, otherwise all of those parameters can be passed directly to the Install-DBOPackage
function without the need to store this in a file.
From what I can see in the error log, the error seems to be happening during the PerformUpgrade() ScriptExecutor.Execute() phase, at which point the connection object should already exist and has checked whether there were any scripts executed in this database already. So we can assume the connectivity or password is not a problem here. Can you attach the first sql file it is about to run? Maybe there's some unexpected parsing issue caused by the DbUp framework.
PS you can use the following syntax too if you want
$config = Get-DBOPackage -Path "$path\package\sqlscripts\DBOPackage.zip" | Get-DBOConfig -Configuration @{
User = 'foo'
Password = ConvertTo-SecureString 'bar' -AsPlainText -Force
...
}
This would grab the configuration from the package object and merge it with the values from the hashtable.
Wow, thank you for the quick response, very impressive. Below is the only script I am attempting to execute in the package.
In regards to your second comment, I tried that before but I will try again to make sure.
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[DatabaseInventory]') AND type IN (N'U'))
BEGIN
/* Create a database table for storing servers */
CREATE TABLE [dbo].[DatabaseInventory] (
[ServerName] NVARCHAR(60) NOT NULL,
[Description] NVARCHAR(60) NULL
)
End
Tried your suggestion, same error, below is a simplified version.
cls
$path = 'D:\GN\db-crm\'
$user = 'user'
$pass = 'pass'
$server = 'server\instance' #tried {{server}},{{port}} & {{server}}\{{instnace}}
$db = 'db'
Invoke-DBOPackageCI -Path "$path\package\sqlscripts\DBOPackage.zip" -ScriptPath "$path\package" -Version 1.0
$config = Get-DBOPackage -Path "$path\package\sqlscripts\DBOPackage.zip" | Get-DBOConfig -Configuration @{
SqlInstance = $server
Database = $db
Username = $user
Password = ConvertTo-SecureString $pass -AsPlainText -Force
}
$config.SaveToFile('.\dev.json')
Get-Content .\dev.json
Install-DBOPackage -Path "$path\package\sqlscripts\DBOPackage.zip" -Configuration .\dev.json -Verbose
Hmm, does the zip file exist by the time you run Invoke-DBOPackageCI
? If so, by using a parent path as a -ScriptPath
parameter, you're adding a zip file as a sql file, which would eventually result in failure to format it.
You can check which files are included by running
$package = Get-DBOPackage -Path "$path\package\sqlscripts\DBOPackage.zip"
$package.Builds.Scripts.Name
Seems like I am missing something. I have re-written this a couple of times to make sure creds, connection, and scripts are correct. But once I go to Install-DBOPackage it fails every time. I have tried using connection string, tried using username and password combo, tried creds only and I get the same error. I have tried plain text password/creds and PSCredential password/creds.
Requirements: Sql Auth creds
Sample script:
Error Message