diff --git a/extensions/sql-database-projects/src/common/constants.ts b/extensions/sql-database-projects/src/common/constants.ts index 38e6b7aaa2..5d07f5aa56 100644 --- a/extensions/sql-database-projects/src/common/constants.ts +++ b/extensions/sql-database-projects/src/common/constants.ts @@ -45,12 +45,6 @@ export const okString = localize('okString', "Ok"); export const extractTargetInput = localize('extractTargetInput', "Select folder structure for SQL files"); export const extractDatabaseSelection = localize('extractDatabaseSelection', "Select database to create project from"); export const selectString = localize('selectString', "Select"); -export const addDatabaseReferenceInput = localize('addDatabaseReferenceInput', "Add database reference for:"); -export const systemDatabaseReferenceInput = localize('systemDatabaseReferenceInput', "System Database:"); -export const databaseReferenceLocation = localize('databaseReferenceLocation', "Database location"); -export const databaseReferenceSameDatabase = localize('databaseReferenceSameDatabase', "Same database"); -export const databaseReferenceDifferentDabaseSameServer = localize('databaseReferenceDifferentDabaseSameServer', "Different database, same server"); -export const databaseReferenceDatabaseName = localize('databaseReferenceDatabaseName', "Database name"); export const dacpacFiles = localize('dacpacFiles', "dacpac Files"); export const publishSettingsFiles = localize('publishSettingsFiles', "Publish Settings File"); export const systemDatabase = localize('systemDatabase', "System Database"); @@ -111,7 +105,7 @@ export const sameDatabase = localize('sameDatabase', "Same database"); export const differentDbSameServer = localize('differentDbSameServer', "Different database, same server"); export const differentDbDifferentServer = localize('differentDbDifferentServer', "Different database, different server"); export const systemDbLocationDropdownValues = [differentDbSameServer]; -export const locationDropdownValues = [differentDbSameServer, differentDbDifferentServer]; +export const locationDropdownValues = [sameDatabase, differentDbSameServer, differentDbDifferentServer]; export const databaseName = localize('databaseName', "Database name"); export const databaseVariable = localize('databaseVariable', "Database variable"); export const serverName = localize('serverName', "Server name"); diff --git a/extensions/sql-database-projects/src/common/utils.ts b/extensions/sql-database-projects/src/common/utils.ts index 68cf04a10c..ac7738d5ea 100644 --- a/extensions/sql-database-projects/src/common/utils.ts +++ b/extensions/sql-database-projects/src/common/utils.ts @@ -8,6 +8,7 @@ import * as os from 'os'; import * as constants from './constants'; import * as path from 'path'; import * as glob from 'fast-glob'; +import * as mssql from '../../../mssql'; import { promises as fs } from 'fs'; /** @@ -228,3 +229,13 @@ export async function getSqlProjectFilesInFolder(folderPath: string): Promise { + const service = (vscode.extensions.getExtension(mssql.extension.name)!.exports as mssql.IExtension).schemaCompare; + const result = await service.schemaCompareGetDefaultOptions(); + + return result.defaultDeploymentOptions; +} diff --git a/extensions/sql-database-projects/src/dialogs/publishDatabaseDialog.ts b/extensions/sql-database-projects/src/dialogs/publishDatabaseDialog.ts index b6c90824d3..4a652705fd 100644 --- a/extensions/sql-database-projects/src/dialogs/publishDatabaseDialog.ts +++ b/extensions/sql-database-projects/src/dialogs/publishDatabaseDialog.ts @@ -183,7 +183,7 @@ export class PublishDatabaseDialog { upgradeExisting: true, connectionUri: await this.getConnectionUri(), sqlCmdVariables: sqlCmdVars, - deploymentOptions: this.deploymentOptions + deploymentOptions: await this.getDeploymentOptions() }; azdata.window.closeDialog(this.dialog); @@ -198,7 +198,7 @@ export class PublishDatabaseDialog { databaseName: this.getTargetDatabaseName(), connectionUri: await this.getConnectionUri(), sqlCmdVariables: sqlCmdVars, - deploymentOptions: this.deploymentOptions + deploymentOptions: await this.getDeploymentOptions() }; azdata.window.closeDialog(this.dialog); @@ -210,6 +210,21 @@ export class PublishDatabaseDialog { this.dispose(); } + private async getDeploymentOptions(): Promise { + // eventually, database options will be configurable in this dialog + // but for now, just send the default DacFx deployment options if no options were loaded from a publish profile + if (!this.deploymentOptions) { + this.deploymentOptions = await utils.GetDefaultDeploymentOptions(); + + // this option needs to be true for same database references validation to work + if (this.project.databaseReferences.length > 0) { + this.deploymentOptions.includeCompositeObjects = true; + } + } + + return this.deploymentOptions; + } + private getSqlCmdVariablesForPublish(): Record { // get SQLCMD variables from table let sqlCmdVariables = { ...this.sqlCmdVars };