“SQL Database” (SqlDatabase
) deployment provider allows incremental publishing of database changes from SQL Server Data Tools (SSDT) package (.dacpac
) to a local SQL Server instance, remote SQL Server or Azure SQL database.
In this guide:
artifact
) - .dacpac
artifact file name or deployment name or regexp matching one of these.connection_string
) - SQL connection string to the target database. Must include database name. For example server=(local)\SQLEXPRESS;database=test101;Integrated security=SSPI;
register_data_tier_application
) - default is false
. You can read about Data-tier applications on MSDN and also there is a nice introductory article on CodeProject.block_when_drift_detected
) - default is false
.Deployment behaviour:
script_database_options
) - Default is true
.create_new_database
) - true
if database should be re-created every time you deploy. Default is false
.block_on_possible_data_loss
) - Prevent database changes if data loss might occur. Default is true
.deploy_database_in_single_user_mode
) - true
to execute deployment script in single-user mode. Default is false
.backup_database_before_changes
) - true
to back up database before deployment. Does not work when publishing to Azure SQL databse. Default is false
.drop_objects_not_in_source
) - true
to remove objects in destination database that do not exist in the package. Default is false
.do_not_drop_users
). Set to true
when DROP objects in target but not in project (drop_objects_not_in_source
) is true
to preserve database users. Default is false
. Important note: to properly preserve users, the following settings also should be set to true
:ignore_permissions
)ignore_user_settings_objects
)ignore_login_sids
)ignore_role_membership
)no_alter_statements_to_change_clr_types
) - Default is false
.Advanced deployment options:
allow_drop_blocking_assemblies
) - This property is used by SqlClr deployment to cause any blocking assemblies to be dropped as part of the deployment plan. By default, any blocking/referencing assemblies will block an assembly update if the referencing assembly needs to be dropped. Default is false
.allow_incompatible_platform
) - Specifies whether to attempt the action despite incompatible SQL Server platforms. Default is false
.comment_out_set_var_declarations
) - Specifies whether the declaration of SETVAR variables should be commented out in the generated publish script. You might choose to do this if you plan to specify the values on the command line when you publish by using a tool such as SQLCMD.EXE. Default is false
.compare_using_target_collation
) - This setting dictates how the database’s collation is handled during deployment; by default the target database’s collation will be updated if it does not match the collation specified by the source. When this option is set, the target database’s (or server’s) collation should be used. Default is false
.disable_and_reenable_ddl_triggers
) - Specifies whether Data Definition Language (DDL) triggers are disabled at the beginning of the publish process and re-enabled at the end of the publish action. Default is true
.do_not_alter_change_data_capture_objects
) - If enabled: true, Change Data Capture objects are not altered. Default is true
.do_not_alter_replicated_objects
) - Specifies whether objects that are replicated are identified during verification. Default is true
.drop_constraints_not_in_source
) - Specifies whether constraints that do not exist in the database snapshot (.dacpac) file will be dropped from the target database when you publish to a database. Default is true
.drop_dml_triggers_not_in_source
) - Specifies whether DML triggers that do not exist in the database snapshot (.dacpac) file will be dropped from the target database when you publish to a database. Default is true
.drop_extended_properties_not_in_source
) - Specifies whether extended properties that do not exist in the database snapshot (.dacpac) file will be dropped from the target database when you publish to a database. Default is true
.drop_indexes_not_in_source
) - Specifies whether indexes that do not exist in the database snapshot (.dacpac) file will be dropped from the target database when you publish to a database. Default is true
.drop_permissions_not_in_source
) - Specifies whether permissions that do not exist in the database snapshot (.dacpac) file will be dropped from the target database when you publish updates to a database. Default is false
.drop_role_members_not_in_source
) - Specifies whether role members that are not defined in the database snapshot (.dacpac) file will be dropped from the target database when you publish updates to a database. Default is false
.generate_smart_defaults
) - Automatically provides a default value when updating a table that contains data with a column that does not allow null values. Default is false
.ignore_ansi_nulls
) - Specifies whether differences in the ANSI NULLS setting should be ignored or updated when you publish to a database. Default is true
.ignore_authorizer
) - Specifies whether differences in the Authorizer should be ignored or updated when you publish to a database. Default is false
.ignore_column_collation
) - Specifies whether differences in the column collations should be ignored or updated when you publish to a database. Default is false
.ignore_comments
) - Specifies whether differences in the comments should be ignored or updated when you publish to a database. Default is false
.ignore_cryptographic_provider_file_path
) - Specifies whether differences in the file path for the cryptographic provider should be ignored or updated when you publish to a database. Default is true
.ignore_ddl_trigger_order
) - Specifies whether differences in the order of Data Definition Language (DDL) triggers should be ignored or updated when you publish to a database or server. Default is false
.ignore_ddl_trigger_state
) - Specifies whether differences in the enabled or disabled state of Data Definition Language (DDL) triggers should be ignored or updated when you publish to a database. Default is false
.ignore_default_schema
) - Specifies whether differences in the default schema should be ignored or updated when you publish to a database. Default is false
.ignore_dml_trigger_order
) - Specifies whether differences in the order of Data Manipulation Language (DML) triggers should be ignored or updated when you publish to a database. Default is false
.ignore_dml_trigger_state
) - Specifies whether differences in the enabled or disabled state of DML triggers should be ignored or updated when you publish to a database. Default is false
.ignore_extended_properties
) - Specifies whether differences in the extended properties should be ignored or updated when you publish to a database. Default is false
.ignore_file_and_log_file_path
) - Specifies whether differences in the paths for files and log files should be ignored or updated when you publish to a database. Default is true
.ignore_filegroup_placement
) - Specifies whether differences in the placement of objects in FILEGROUPs should be ignored or updated when you publish to a database. Default is true
.ignore_file_size
) - Specifies whether differences in the file sizes should be ignored or whether a warning should be issued when you publish to a database. Default is true
.ignore_fill_factor
) - Specifies whether differences in the fill factor for index storage should be ignored or whether a warning should be issued when you publish to a database. Default is true
.ignore_full_text_catalog_file_path
) - Specifies whether differences in the file path for the full-text catalog should be ignored or whether a warning should be issued when you publish to a database. Default is true
.ignore_identity_seed
) - Specifies whether differences in the seed for an identity column should be ignored or updated when you publish updates to a database. Default is false
.ignore_increment
) - Specifies whether differences in the increment for an identity column should be ignored or updated when you publish to a database. Default is false
.ignore_index_options
) - Specifies whether differences in the index options should be ignored or updated when you publish to a database. Default is false
.ignore_index_padding
) - Specifies whether differences in the index padding should be ignored or updated when you publish to a database. Default is true
.ignore_keyword_casing
) - Specifies whether differences in the casing of keywords should be ignored or updated when you publish to a database. Default is true
.ignore_lock_hints_on_indexes
) - Specifies whether differences in the lock hints on indexes should be ignored or updated when you publish to a database. Default is false
.ignore_login_sids
) - Specifies whether differences in the security identification number (SID) should be ignored or updated when you publish to a database. Default is true
.ignore_not_for_replication
) - Specifies whether the not for replication settings should be ignored or updated when you publish to a database. Default is false
.ignore_object_placement_on_partition_scheme
) - Specifies whether an object’s placement on a partition scheme should be ignored or updated when you publish to a database. Default is true
.ignore_partition_schemes
) - Specifies whether differences in partition schemes and functions should be ignored or updated when you publish to a database. Default is false
.ignore_permissions
) - Specifies whether differences in the permissions should be ignored or updated when you publish to a database. Default is false
.ignore_quoted_identifiers
) - Specifies whether differences in the quoted identifiers setting should be ignored or updated when you publish to a database. Default is true
.ignore_role_membership
) - Specifies whether differences in the role membership of logins should be ignored or updated when you publish to a database. Default is false
.ignore_route_lifetime
) - Specifies whether differences in the amount of time that SQL Server retains the route in the routing table should be ignored or updated when you publish to a database. Default is true
.ignore_semicolon_between_statements
) - Specifies whether differences in the semi-colons between T-SQL statements will be ignored or updated when you publish to a database. Default is true
.ignore_table_options
) - Specifies whether differences in the table options will be ignored or updated when you publish to a database. Default is false
.ignore_user_settings_objects
) - Specifies whether differences in the user settings objects will be ignored or updated when you publish to a database. Default is false
.ignore_whitespace
) - Specifies whether differences in white space will be ignored or updated when you publish to a database. Default is true
.ignore_with_nocheck_on_check_constraints
) - Specifies whether differences in the value of the WITH NOCHECK clause for check constraints will be ignored or updated when you publish to a database. Default is false
.ignore_with_nocheck_on_foreign_keys
) - Specifies whether differences in the value of the WITH NOCHECK clause for foreign keys will be ignored or updated when you publish to a database. Default is false
.include_composite_objects
) - Include all composite elements as part of a single publish operation. Default is true
.include_transactional_scripts
) - Specifies whether transactional statements should be used where possible when you publish to a database. Default is false
.populate_files_on_file_groups
) - Specifies whether a new file is also created when a new FileGroup is created in the target database. Default is true
.script_database_collation
) - Specifies whether differences in the database collation should be ignored or updated when you publish to a database. Default is false
.script_database_compatibility
) - Specifies whether differences in the database compatibility should be ignored or updated when you publish to a database. Default is false
.script_deploy_state_checks
) - Specifies whether statements are generated in the publish script to verify that the database name and server name match the names specified in the database project. Default is false
.script_file_size
) - Controls whether size is specified when adding a file to a filegroup. Default is false
.script_new_constraint_validation
) - At the end of publish all of the constraints will be verified as one set, avoiding data errors caused by a check or foreign key constraint in the middle of publish. If set to enabled: false, your constraints will be published without checking the corresponding data. Default is true
.script_refresh_module
) - Include refresh statements at the end of the publish script. Default is true
.treat_verification_errors_as_warnings
) - Specifies whether errors encountered during publish verification should be treated as warnings. The check is performed against the generated deployment plan before the plan is executed against your target database. Plan verification detects problems such as the loss of target-only objects (such as indexes) that must be dropped to make a change. Verification will also detect situations where dependencies (such as a table or view) exist because of a reference to a composite project, but do not exist in the target database. You might choose to do this to get a complete list of all issues, instead of having the publish action stop on the first error. Default is false
.unmodifiable_object_warnings
) - Specifies whether warnings should be generated when differences are found in objects that cannot be modified, for example, if the file size or file paths were different for a file. Default is true
.verify_collation_compatibility
) - Specifies whether collation compatibility is verified. Default is true
.verify_deployment
) - Specifies whether checks should be performed before publishing that will stop the publish action if issues are present that might block successful publishing. For example, your publish action might stop if you have foreign keys on the target database that do not exist in the database project, and that will cause errors when you publish. Default is true
.At minimum you would specify just artifact
and connection_string
and rely on default values for database deployment settings described above. The following settings work for the most cases when deploying to SQL Server or Azure SQL:
deploy:
provider: SqlDatabase
connection_string:
secure: r5FHTTIfknKXrvMwsfqC/swG2n81GGc0PruruI5DVSMAocqz==
script_database_options: false
ignore_file_and_log_file_path: true
You can specify SQLCMD variables either on UI or in appveyor.yml
by prefixing them with sqlcmd.
, for example:
deploy:
provider: SqlDatabase
connection_string:
secure: r5FHTTIfknKXrvMwsfqC/swG2n81GGc0PruruI5DVSMAocqz==
sqlcmd.VarName: Boo
sqlcmd.AnotherVar: Baz
To perform integration testing of database changes you can publish SSDT package to a local SQL Server instance installed on build worker. SQL Server 2008, SQL Server 2012 and SQL Server 2014 instances are available on build worker for your tests.
By default, all SQL Server services are stopped. You can choose SQL Server service to start on “Environment” tab of AppVeyor project settings or in appveyor.yml
. For example, to start SQL Server 2014 instance:
services:
- mssql2014
In connection string for local publishing you could either use standard SQL Server login/password or integrated security (Integrated Security=SSPI
). Below is a complete example of appveyor.yml
for building SSDT package, pushing it to build artifacts and then publishing to a local SQL Server:
services:
- mssql2014
artifacts:
- path: MyDatabase\bin\debug\MyDatabase.dacpac
name: MyDatabase
deploy:
- provider: SqlDatabase
artifact: MyDatabase
connection_string: 'Server=(local)\SQL2014;Database=my_test_db;User ID=sa;Password=Password12!'
To enable database publishing from AppVeyor environment to your Azure SQL database you should modify Azure SQL Server firewall settings and allow Windows Azure Services add the following ranges of allowed IPs.
In Visual Studio open SSDT project properties and select Microsoft Azure SQL Database as a Target platform:
If target SQL Server instance is behind the firewall you can still publish database there by installing AppVeyor Deployment Agent.
For instructions on setting up database publishing with Deployment Agent please see Publishing SSDT package artifact to SQL Server section in Deployment Agent guide.