Invoke-DevartSyncDatabaseSchema

Synopsis

Compares and synchronizes schemas.

Description

The cmdlet updates a target database to match a source database schema.

Syntax

Invoke-DevartSyncDatabaseSchema -Source <object> -Target <object> [-FilterPath <string>] [-QueryBatchTimeout <int>] 
[-Report <SwitchParameter>] [-ReportFilePath <string>] [-ReportFormat <string>] [-SynchronizationOptions <string>] 
[-TransactionIsolationLevel <string>] [<CommonParameters>]

Parameters

-Source

Specifies the source as a live database or database objects loaded from a scripts folder or a NuGet package.

-Source <object>
Property Default value
Required True
Position Named
Default value -
Accept pipeline input False
Accept wildcard characters False

-Target

Specifies the target schema to be updated.

-Target <object>
Property Default value
Required True
Position Named
Default value -
Accept pipeline input False
Accept wildcard characters False

-FilterPath

Specifies the path to the file containing the filter settings during schema synchronization.

-FilterPath <string>
Property Default value
Required False
Position Named
Default value -
Accept pipeline input False
Accept wildcard characters False

-QueryBatchTimeout

Controls how long a SQL query can run before PowerShell stops it. This parameter applies to each expression in the synchronization script. This parameter is ignored unless the target is a DevartDatabaseConnectionInfo object.

-QueryBatchTimeout <int>
Property Default value
Required False
Position Named
Default value 30
Accept pipeline input False
Accept wildcard characters False

-Report

Generates a schema comparison report.

-Report <SwitchParameter>
Property Default value
Required False
Position Named
Default value False
Accept pipeline input False
Accept wildcard characters False

-ReportFilePath

Specifies the path to the report file.

-ReportFilePath <string>
Property Default value
Required False
Position Named
Default value -
Accept pipeline input False
Accept wildcard characters False

-ReportFormat

Specifies the format of the comparison report. The available formats are: HTML, XLS, XML, and XMLFOREXCEL.

-ReportFormat <string>
Property Default value
Required False
Position Named
Default value Html
Accept pipeline input False
Accept wildcard characters False

-SynchronizationOptions

Specifies the schema comparison options to generate a synchronization script.

-SynchronizationOptions <string>

To include additional options, specify a list of the options, for example:

/IgnoreCase:Yes /IgnorePrimaryKeys:No
Property Default value
Required False
Position Named
Default value -
Accept pipeline input False
Accept wildcard characters False

For more information about synchronization options, see Command-line options.

-TransactionIsolationLevel

Specifies the isolation level for the transactions during the temporary deployment for validation. The available options are: Serializable (default), Snapshot, RepeatableRead, ReadCommitted and ReadUncommitted.

-TransactionIsolationLevel <string>
Property Default value
Required False
Position Named
Default value Serializable
Accept pipeline input False
Accept wildcard characters False

Common parameters

<CommonParameters>

This cmdlet supports these common parameters:

  • Verbose – Provides detailed output about the command operation.
  • Debug – Provides debugging information.
  • ErrorAction – Specifies how to respond to errors.
  • ErrorVariable – Stores error messages in a variable.
  • WarningAction – Specifies how to respond to warnings.
  • WarningVariable – Stores warning messages in a variable.
  • InformationAction – Specifies how informational messages are handled.
  • InformationVariable – Stores informational messages in a variable.
  • OutBuffer – Controls the number of objects buffered before output.
  • PipelineVariable – Stores the current pipeline object in a variable.
  • OutVariable – Stores output objects in a variable.

For more information, see About Common Parameters.

Output

System.Boolean (returns true on success and false otherwise)

System.Boolean returns:

  • true if the operation was successful.
  • false if the operation failed.

Example

$syncResult = Invoke-DevartSyncDatabaseSchema -Source $connection -Target $targetConnection

Note

The Invoke-DevartSyncDatabaseSchema cmdlet synchronizes the source and target databases when it runs. It automatically includes the /sync switch, which triggers the synchronization process.

To generate a comparison report without synchronization, use the command-line interface available in the Enterprise or Professional editions of dbForge Studio for SQL Server and omit the /sync switch. For example:

"C:\Program Files\Devart\dbForge Studio for SQL Server\dbforgesql.com" /schemacompare /source connection:"Data Source=<source_connection>;Initial Catalog=A1;Integrated Security=False;User ID=<source_username>" /target connection:"Data Source=<target_connection>;Initial Catalog=A2;Integrated Security=False;User ID=<target_username>"

To implement custom solutions in your DevOps pipeline, use the dbForge Studio command line to tailor the command with the required options and parameters for your specific tasks.

Related links

For information on additional command-line options, see Command-line options.

For information about how to generate a file containing filter options, see Using Object Filter.