Options

Sync-DatabaseSchema fails Invalid Type Source Parameter from Invoke-DatabaseBuild

I get this error 
A invalid type was passed to Sync-DatabaseSchema for the Source parameter: 'C:\Code\Proto\UnitTestSandbox\UnitTestSandbox.DB\UnitTestSandbox.DB.sqlproj'

on the last line of this powershell script which I lifted from the documentation.

$errorActionPreference = "stop"
 
# Validate the SQL Change Automation project
$project = "C:\Code\Proto\UnitTestSandbox\UnitTestSandbox.DB\UnitTestSandbox.DB.sqlproj" # The SQL Change Automation project to validate, test and sync
$validatedProject = Invoke-DatabaseBuild $project

$validatedProject

# Sync a test database
$deploymentTargetConnection = New-DatabaseConnection -ServerInstance "db" -Database "AutoTestJunk220" # Update this to use the blank database created earlier
Test-DatabaseConnection $deploymentTargetConnection
Sync-DatabaseSchema
What do I need to do different?
Tagged:

Best Answers

  • Options
    Sergio RSergio R Posts: 610 Rose Gold 5
    It's not possible to use the SCA Project file as an input for the Sync-DatabaseSchema cmdlet
    You need to add New-DatabaseBuildArtifact  and then use its output as an input to the Sync-DatabaseSchema operation, for example:

    <div>$artifact = New-DatabaseBuildArtifact -InputObject $validatedProject -PackageId 99999 -PackageVersion 1.0.0</div><div><br></div><div><br></div><div>Sync-DatabaseSchema -Source $artifact -Target "Data Source=SQLServer;Initial Catalog=MyDB"</div>
    Sergio
    Product Support Engineer
    Redgate Software Ltd
    Please see our Help Center for detailed guides on how to use our tools
  • Options
    Sergio RSergio R Posts: 610 Rose Gold 5
    You understood it correctly, however that only works for SQL Source Control projects. Thanks for the feedback, I will get that corrected.
    Sergio
    Product Support Engineer
    Redgate Software Ltd
    Please see our Help Center for detailed guides on how to use our tools
  • Options
    Sergio RSergio R Posts: 610 Rose Gold 5
    We have now corrected our documentation
    Sergio
    Product Support Engineer
    Redgate Software Ltd
    Please see our Help Center for detailed guides on how to use our tools

Answers

Sign In or Register to comment.