Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow additional properties to be specified when running the SQL dacpac tooling #1386

Merged
merged 1 commit into from
Oct 6, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions src/app/FakeLib/Sql.DacPac.fs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ type DeployDbArgs = {
/// Drops objects in the destination that do not exist in the source. Defaults to false.
DropObjectsNotInSource : bool
/// Recreates the database from scratch on publish (rather than an in-place update). Defaults to false.
RecreateDb : bool }
RecreateDb : bool
/// Additional configuration parameters required by sqlpackage.exe
AdditionalSqlPackageProperties : (string * string) list }

let validPaths =
let getSqlVersion (path:string) = path.Split '\\' |> Array.item 3 |> int
Expand All @@ -57,7 +59,12 @@ let defaultDeploymentArgs =
Timeout = 120
BlockOnPossibleDataLoss = true
DropObjectsNotInSource = false
RecreateDb = false }
RecreateDb = false
AdditionalSqlPackageProperties = [] }

module PropertyKeys =
/// When creating a new SQL Azure database, specifies the database service tier to use e.g. S2, P1
let sqlAzureDbSize = "DatabaseServiceObjective"

let private generateCommandLine args =
let action, outputPath =
Expand All @@ -73,6 +80,11 @@ let deployDb setParams =
let args = setParams defaultDeploymentArgs
let action, outputPath = generateCommandLine args.Action

let additionalParameters =
args.AdditionalSqlPackageProperties
|> List.map (fun (key, value) -> sprintf "/p:%s=%s" key value)
|> String.concat " "

if System.String.IsNullOrWhiteSpace args.SqlPackageToolPath then
failwith "No SqlPackage.exe filename was given."

Expand All @@ -81,7 +93,7 @@ let deployDb setParams =

shellExec {
Program = args.SqlPackageToolPath
CommandLine = sprintf """/Action:%s /SourceFile:"%s" /TargetConnectionString:"%s" %s /p:BlockOnPossibleDataLoss=%b /p:DropObjectsNotInSource=%b /p:CommandTimeout=%d /p:CreateNewDatabase=%b""" action args.Source args.Destination outputPath args.BlockOnPossibleDataLoss args.DropObjectsNotInSource args.Timeout args.RecreateDb
CommandLine = sprintf """/Action:%s /SourceFile:"%s" /TargetConnectionString:"%s" %s /p:BlockOnPossibleDataLoss=%b /p:DropObjectsNotInSource=%b /p:CommandTimeout=%d /p:CreateNewDatabase=%b %s""" action args.Source args.Destination outputPath args.BlockOnPossibleDataLoss args.DropObjectsNotInSource args.Timeout args.RecreateDb additionalParameters
WorkingDirectory = ""
Args = [] }

Expand Down