Sync-DlmDatabaseSchema
Published 10 March 2016
Sync-DlmDatabaseSchema
Updates a target database schema to match a source database schema.
Syntax
Sync-DlmDatabaseSchema -Source <Object> -Target <DatabaseConnection> [-FilterPath <string>] [-IgnoreStaticData] [-IgnoreAdditional] [-SQLCompareOptions <string>] [-TransactionIsolationLevel <TransactionIsolationLevel>] [-QueryBatchTimeout <int>] [-AbortOnWarningLevel <WarningSeverity>] [-IgnoreParserErrors] [<CommonParameters>]
|
Description
The Sync-DlmDatabaseSchema cmdlet updates a target database to match a source database schema.
The source schema can be a database connection, a NuGet package, or a scripts folder. The target schema must be a database connection.
Parameters
-Source
<System.Object>
The source database schema used to update the target database. This can be:
- a Database Connection object created by the New-DlmDatabaseConnection cmdlet
- a database connection string
- a path for a NuGet package or .zip file. This must contain a scripts folder located at db\state
- a Database Package object produced by the New-DlmDatabasePackage cmdlet
- a path for a scripts folder, created by SQL Compare or from your SQL Source Control database repository
Aliases | None |
Required? | true |
Position? | named |
Default Value | None |
Accept Pipeline Input | false |
Accept Wildcard Characters | false |
-Target
<RedGate.DLMAutomation.Compare.SchemaSources.DatabaseConnection>
The target database to be updated. This can be:
- a Database Connection object created by the New-DlmDatabaseConnection cmdlet
- a database connection string
Aliases | None |
Required? | true |
Position? | named |
Default Value | None |
Accept Pipeline Input | false |
Accept Wildcard Characters | false |
-FilterPath
<System.String>
The path to a .scpf filter file.
Use this parameter to specify a filter file to be used when performing the sync operation. This will override any Filter.scpf file in the source.
Aliases | None |
Required? | false |
Position? | named |
Default Value | None |
Accept Pipeline Input | false |
Accept Wildcard Characters | false |
-IgnoreStaticData
<System.Management.Automation.SwitchParameter>
When DLM Automation performs a sync operation and the source is a NuGet package or a scripts folder, by default it will include static data flagged by SQL Source Control.
If you specify this parameter, static data will be ignored.
Aliases | None |
Required? | false |
Position? | named |
Default Value | False |
Accept Pipeline Input | false |
Accept Wildcard Characters | false |
-IgnoreAdditional
<System.Management.Automation.SwitchParameter>
When DLM Automation performs a sync operation, by default it will drop all additional objects in the target database.
If you specify this parameter, additional objects will be ignored.
Enabling this prevents new and unexpected objects in the target being dropped - note that the checks and tests applied to this database may not have taken those objects into account and may therefore not be valid.
This parameter can't be used simultaneously with filter files.
Aliases | None |
Required? | false |
Position? | named |
Default Value | False |
Accept Pipeline Input | false |
Accept Wildcard Characters | false |
-SQLCompareOptions
<System.String>
Specifies the SQL Compare options to use when performing the sync operation. DLM Automation applies a default set of options (listed below). To include additional options, specify a comma-delimited list of the option names (eg 'IgnoreComments, ObjectExistenceChecks'). To turn off a default option, precede the option name with a minus sign (eg '-ForceColumnOrder').
This parameter will be ignored if the value specified is $null or empty.
By default, the following Compare options are used:
- ConsiderNextFilegroupInPartitionSchemes
- DecryptPost2KEncryptedObjects
- DoNotOutputCommentHeader
- ForceColumnOrder
- IgnoreCertificatesAndCryptoKeys
- IgnoreDatabaseAndServerName
- IgnoreTSQLT
- IgnoreUsersPermissionsAndRoleMemberships
- IgnoreUserProperties
- IgnoreWhiteSpace
- IgnoreWithElementOrder
- IncludeDependencies
- ThrowOnFileParseFailed
- UseCompatibilityLevel
For more information about SQL Compare options, see http://www.red-gate.com/dlma/compareoptions.
Aliases | None |
Required? | false |
Position? | named |
Default Value | None |
Accept Pipeline Input | false |
Accept Wildcard Characters | false |
-TransactionIsolationLevel
<RedGate.DLMAutomation.Shared.Domain.TransactionIsolationLevel>
Use this parameter to specify the isolation level for the transactions during the sync operation. Permitted values are: Serializable, Snapshot, RepeatableRead, ReadCommitted and ReadUncommitted. The default level is Serializable.
See http://msdn.microsoft.com/en-gb/library/ms173763.aspx for more details on transaction isolation levels.
Possible values: Serializable, Snapshot, RepeatableRead, ReadCommitted, ReadUncommitted
Aliases | None |
Required? | false |
Position? | named |
Default Value | Serializable |
Accept Pipeline Input | false |
Accept Wildcard Characters | false |
-QueryBatchTimeout
<System.Int32>
The execution timeout, in seconds, for each batch of queries during the sync operation. The default value is 30 seconds. A value of zero indicates that no execution timeout will be enforced.
Aliases | None |
Required? | false |
Position? | named |
Default Value | 0 |
Accept Pipeline Input | false |
Accept Wildcard Characters | false |
-AbortOnWarningLevel
<RedGate.DLMAutomation.Shared.Domain.WarningSeverity>
Use this parameter to set the minimum warning level that will cause the sync operation to abort.
Valid warning severity levels are:
- High
- Medium
- Low
- Information
- None (do not abort for any warnings)
The default setting is 'High'.
This parameter can't be used in addition to the Force parameter.
Possible values: Information, Low, Medium, High, None
Aliases | None |
Required? | false |
Position? | named |
Default Value | High |
Accept Pipeline Input | false |
Accept Wildcard Characters | false |
-Force
<System.Management.Automation.SwitchParameter>
Use this parameter to prevent the sync operation from aborting regardless of any warnings.
An alternative way of doing this is to set the AbortOnWarningLevel to 'None'.
This parameter can't be used in addition to the AbortOnWarningLevel parameter.
Aliases | None |
Required? | false |
Position? | named |
Default Value | False |
Accept Pipeline Input | false |
Accept Wildcard Characters | false |
-IgnoreParserErrors
<System.Management.Automation.SwitchParameter>
Use this parameter to force the SQL Compare engine to ignore any parser errors.
Aliases | None |
Required? | false |
Position? | named |
Default Value | False |
Accept Pipeline Input | false |
Accept Wildcard Characters | false |
<CommonParameters>
This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see http://technet.microsoft.com/en-us/library/hh847884.aspx.
Inputs
The input type is the type of the objects that you can pipe to the cmdlet.
-
None.
You cannot pipe input to this cmdlet.
Return values
The output type is the type of the objects that the cmdlet emits.
- RedGate.DLMAutomation.Compare.Domain.DatabaseSyncResult
Examples
---------- EXAMPLE 1 ----------
|
This example show how to update a test database to match a scripts folder.
---------- EXAMPLE 2 ----------
|
This example shows how to update a test database to match a validated scripts folder.
---------- EXAMPLE 3 ----------
|
This example shows how to abort the update if there are any warnings at medium level or above.
Set the -AbortOnWarningLevel parameter to 'None' or use the Force parameter if you want the cmdlet to ignore all warnings.
---------- EXAMPLE 4 ----------
|
This example show how to write the updateScript that was run to a file.
---------- EXAMPLE 5 ----------
|
This example shows how to specify SQL Compare options to use when performing the sync operation.
In this example, the $options variable specifies that the IgnoreComments and ObjectExistenceChecks options should be included in addition to the default set of SQL Compare options. The minus sign before the ForceColumnOrder parameter indicates that this default option will be turned off.