Hook up sql proj publish (#16444)

This commit is contained in:
Charles Gagnon
2021-07-27 09:32:42 -07:00
committed by GitHub
parent 24349885d3
commit b2c203eaef
7 changed files with 95 additions and 47 deletions

View File

@@ -11,7 +11,7 @@ import * as utils from '../common/utils';
import { Project } from '../models/project';
import { SqlConnectionDataSource } from '../models/dataSources/sqlConnectionStringSource';
import { IDeploySettings } from '../models/IDeploySettings';
import { DeploymentOptions, SchemaObjectType } from '../../../mssql/src/mssql';
import { DeploymentOptions } from '../../../mssql/src/mssql';
import { IconPathHelper } from '../common/iconHelper';
import { cssStyles } from '../common/uiConstants';
import { getConnectionName } from './utils';
@@ -221,15 +221,8 @@ export class PublishDatabaseDialog {
// 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();
// re-include database-scoped credentials
this.deploymentOptions.excludeObjectTypes = this.deploymentOptions.excludeObjectTypes.filter(x => x !== SchemaObjectType.DatabaseScopedCredentials);
// this option needs to be true for same database references validation to work
if (this.project.databaseReferences.length > 0) {
this.deploymentOptions.includeCompositeObjects = true;
}
// We only use the dialog in ADS context currently so safe to cast to the mssql DeploymentOptions here
this.deploymentOptions = await utils.getDefaultPublishDeploymentOptions(this.project) as DeploymentOptions;
}
return this.deploymentOptions;

View File

@@ -8,13 +8,15 @@ import * as constants from '../common/constants';
import { Project } from '../models/project';
import { PublishProfile, readPublishProfile } from '../models/publishProfile/publishProfile';
import { promptForPublishProfile } from './publishDatabaseDialog';
import { getVscodeMssqlApi } from '../common/utils';
import { getDefaultPublishDeploymentOptions, getVscodeMssqlApi } from '../common/utils';
import { IConnectionInfo } from 'vscode-mssql';
import { ProjectsController } from '../controllers/projectController';
import { IDeploySettings } from '../models/IDeploySettings';
/**
* Create flow for Publishing a database using only VS Code-native APIs such as QuickPick
*/
export async function launchPublishDatabaseQuickpick(project: Project): Promise<void> {
export async function launchPublishDatabaseQuickpick(project: Project, projectController: ProjectsController): Promise<void> {
// 1. Select publish settings file (optional)
// Create custom quickpick so we can control stuff like displaying the loading indicator
@@ -192,12 +194,13 @@ export async function launchPublishDatabaseQuickpick(project: Project): Promise<
// TODO@chgagnon: Get deployment options
// 6. Generate script/publish
// let settings: IDeploySettings | IGenerateScriptSettings = {
// databaseName: databaseName,
// serverName: connectionProfile!.server,
// connectionUri: '', // TODO@chgagnon: Get from connection profile
// sqlCmdVariables: sqlCmdVariables,
// deploymentOptions: undefined, // await this.getDeploymentOptions(),
// profileUsed: !!publishProfile
// };
let settings: IDeploySettings = {
databaseName: databaseName,
serverName: connectionProfile!.server,
connectionUri: connectionUri,
sqlCmdVariables: sqlCmdVariables,
deploymentOptions: await getDefaultPublishDeploymentOptions(project),
profileUsed: !!publishProfile
};
await projectController.publishOrScriptProject(project, settings, action === constants.publish);
}