I have a SQL script which copies some data to our test DB which needs to be run on each deployment.
I first tried creating a package and a step along the lines of http://octopusdeploy.com/blog/howto/deploy-a-sql-database
which contained the SQL script and a Deploy.ps1 to run it.
That ran OK the first time but after that it doesn’t run again unless I ‘Force redeployment’ which isn’t very satisfactory.
The only other thing I can think to try is putting the SQL script and a Deploy.ps1 in the website package but that, I think, would mean including the SQL script in the website project which I don’t want to do.
I guess I could put the SQL script on a network share or a path on the deployment machine and put the full path to it in Deploy.ps1
If this gets implemented: http://octopusdeploy.uservoice.com/forums/170787-general/suggestions/3721946-ability-to-run-a-powershell-script-once-before, it would be good to be able to run it from there.
Any other ideas?
For reference my Deploy.ps1:
@@@
if ( Get-PSSnapin -Registered | where {$.name -eq ‘SqlServerProviderSnapin100’} )
{
if( !(Get-PSSnapin | where {$.name -eq ‘SqlServerProviderSnapin100’}))
{
Add-PSSnapin SqlServerProviderSnapin100 | Out-Null
} ;
if( !(Get-PSSnapin | where {$.name -eq ‘SqlServerCmdletSnapin100’}))
{
Add-PSSnapin SqlServerCmdletSnapin100 | Out-Null
}
}
else
{
if( !(Get-Module | where {$.name -eq ‘sqlps’}))
{
Import-Module ‘sqlps’ –DisableNameChecking
}
}
Invoke-Sqlcmd -server *** -Database *** -Username *** -Password *** -Verbose -InputFile “Reload_Reports.sql” | Write-Host
@@@