mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-21 01:25:37 -05:00
Update dacpac and schema compare extensions to use getConnections() (#6131)
* update dacpac and schema compare extensions to use getConnections * use more const * make MSSQL a const * changing name of mssql const * add comment for name of parameter
This commit is contained in:
@@ -46,7 +46,7 @@ export abstract class BasePage {
|
||||
public abstract setupNavigationValidator();
|
||||
|
||||
protected async getServerValues(): Promise<{ connection, displayName, name }[]> {
|
||||
let cons = await azdata.connection.getActiveConnections();
|
||||
let cons = await azdata.connection.getConnections(/* activeConnectionsOnly */ true);
|
||||
// This user has no active connections ABORT MISSION
|
||||
if (!cons || cons.length === 0) {
|
||||
return undefined;
|
||||
|
||||
@@ -167,6 +167,6 @@ export abstract class DacFxConfigPage extends BasePage {
|
||||
}
|
||||
|
||||
interface ConnectionDropdownValue extends azdata.CategoryValue {
|
||||
connection: azdata.connection.Connection;
|
||||
connection: azdata.connection.ConnectionProfile;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import * as azdata from 'azdata';
|
||||
* Data model to communicate between DacFx pages
|
||||
*/
|
||||
export interface DacFxDataModel {
|
||||
server: azdata.connection.Connection;
|
||||
server: azdata.connection.ConnectionProfile;
|
||||
database: string;
|
||||
serverName: string;
|
||||
serverId: string;
|
||||
|
||||
@@ -17,7 +17,7 @@ import { DacFxDataModel } from './api/models';
|
||||
import { BasePage } from './api/basePage';
|
||||
|
||||
const localize = nls.loadMessageBundle();
|
||||
|
||||
const msSqlProvider = 'MSSQL';
|
||||
class Page {
|
||||
wizardPage: azdata.window.WizardPage;
|
||||
dacFxPage: BasePage;
|
||||
@@ -252,10 +252,10 @@ export class DataTierApplicationWizard {
|
||||
}
|
||||
|
||||
private async deploy() {
|
||||
let service = await DataTierApplicationWizard.getService(this.model.server.providerName);
|
||||
let ownerUri = await azdata.connection.getUriForConnection(this.model.server.connectionId);
|
||||
const service = await DataTierApplicationWizard.getService(msSqlProvider);
|
||||
const ownerUri = await azdata.connection.getUriForConnection(this.model.server.connectionId);
|
||||
|
||||
let result = await service.deployDacpac(this.model.filePath, this.model.database, this.model.upgradeExisting, ownerUri, azdata.TaskExecutionMode.execute);
|
||||
const result = await service.deployDacpac(this.model.filePath, this.model.database, this.model.upgradeExisting, ownerUri, azdata.TaskExecutionMode.execute);
|
||||
if (!result || !result.success) {
|
||||
vscode.window.showErrorMessage(
|
||||
localize('alertData.deployErrorMessage', "Deploy failed '{0}'", result.errorMessage ? result.errorMessage : 'Unknown'));
|
||||
@@ -263,10 +263,10 @@ export class DataTierApplicationWizard {
|
||||
}
|
||||
|
||||
private async extract() {
|
||||
let service = await DataTierApplicationWizard.getService(this.model.server.providerName);
|
||||
let ownerUri = await azdata.connection.getUriForConnection(this.model.server.connectionId);
|
||||
const service = await DataTierApplicationWizard.getService(msSqlProvider);
|
||||
const ownerUri = await azdata.connection.getUriForConnection(this.model.server.connectionId);
|
||||
|
||||
let result = await service.extractDacpac(this.model.database, this.model.filePath, this.model.database, this.model.version, ownerUri, azdata.TaskExecutionMode.execute);
|
||||
const result = await service.extractDacpac(this.model.database, this.model.filePath, this.model.database, this.model.version, ownerUri, azdata.TaskExecutionMode.execute);
|
||||
if (!result || !result.success) {
|
||||
vscode.window.showErrorMessage(
|
||||
localize('alertData.extractErrorMessage', "Extract failed '{0}'", result.errorMessage ? result.errorMessage : 'Unknown'));
|
||||
@@ -274,10 +274,10 @@ export class DataTierApplicationWizard {
|
||||
}
|
||||
|
||||
private async export() {
|
||||
let service = await DataTierApplicationWizard.getService(this.model.server.providerName);
|
||||
let ownerUri = await azdata.connection.getUriForConnection(this.model.server.connectionId);
|
||||
const service = await DataTierApplicationWizard.getService(msSqlProvider);
|
||||
const ownerUri = await azdata.connection.getUriForConnection(this.model.server.connectionId);
|
||||
|
||||
let result = await service.exportBacpac(this.model.database, this.model.filePath, ownerUri, azdata.TaskExecutionMode.execute);
|
||||
const result = await service.exportBacpac(this.model.database, this.model.filePath, ownerUri, azdata.TaskExecutionMode.execute);
|
||||
if (!result || !result.success) {
|
||||
vscode.window.showErrorMessage(
|
||||
localize('alertData.exportErrorMessage', "Export failed '{0}'", result.errorMessage ? result.errorMessage : 'Unknown'));
|
||||
@@ -285,10 +285,10 @@ export class DataTierApplicationWizard {
|
||||
}
|
||||
|
||||
private async import() {
|
||||
let service = await DataTierApplicationWizard.getService(this.model.server.providerName);
|
||||
let ownerUri = await azdata.connection.getUriForConnection(this.model.server.connectionId);
|
||||
const service = await DataTierApplicationWizard.getService(msSqlProvider);
|
||||
const ownerUri = await azdata.connection.getUriForConnection(this.model.server.connectionId);
|
||||
|
||||
let result = await service.importBacpac(this.model.filePath, this.model.database, ownerUri, azdata.TaskExecutionMode.execute);
|
||||
const result = await service.importBacpac(this.model.filePath, this.model.database, ownerUri, azdata.TaskExecutionMode.execute);
|
||||
if (!result || !result.success) {
|
||||
vscode.window.showErrorMessage(
|
||||
localize('alertData.importErrorMessage', "Import failed '{0}'", result.errorMessage ? result.errorMessage : 'Unknown'));
|
||||
@@ -296,15 +296,15 @@ export class DataTierApplicationWizard {
|
||||
}
|
||||
|
||||
private async generateDeployScript() {
|
||||
let service = await DataTierApplicationWizard.getService(this.model.server.providerName);
|
||||
let ownerUri = await azdata.connection.getUriForConnection(this.model.server.connectionId);
|
||||
const service = await DataTierApplicationWizard.getService(msSqlProvider);
|
||||
const ownerUri = await azdata.connection.getUriForConnection(this.model.server.connectionId);
|
||||
this.wizard.message = {
|
||||
text: localize('dacfx.scriptGeneratingMessage', 'You can view the status of script generation in the Tasks View once the wizard is closed. The generated script will open when complete.'),
|
||||
level: azdata.window.MessageLevel.Information,
|
||||
description: ''
|
||||
};
|
||||
|
||||
let result = await service.generateDeployScript(this.model.filePath, this.model.database, ownerUri, azdata.TaskExecutionMode.script);
|
||||
const result = await service.generateDeployScript(this.model.filePath, this.model.database, ownerUri, azdata.TaskExecutionMode.script);
|
||||
if (!result || !result.success) {
|
||||
vscode.window.showErrorMessage(
|
||||
localize('alertData.deployErrorMessage', "Deploy failed '{0}'", result.errorMessage ? result.errorMessage : 'Unknown'));
|
||||
@@ -351,10 +351,10 @@ export class DataTierApplicationWizard {
|
||||
}
|
||||
|
||||
public async generateDeployPlan(): Promise<string> {
|
||||
let service = await DataTierApplicationWizard.getService(this.model.server.providerName);
|
||||
let ownerUri = await azdata.connection.getUriForConnection(this.model.server.connectionId);
|
||||
const service = await DataTierApplicationWizard.getService(msSqlProvider);
|
||||
const ownerUri = await azdata.connection.getUriForConnection(this.model.server.connectionId);
|
||||
|
||||
let result = await service.generateDeployPlan(this.model.filePath, this.model.database, ownerUri, azdata.TaskExecutionMode.execute);
|
||||
const result = await service.generateDeployPlan(this.model.filePath, this.model.database, ownerUri, azdata.TaskExecutionMode.execute);
|
||||
|
||||
if (!result || !result.success) {
|
||||
vscode.window.showErrorMessage(
|
||||
@@ -365,7 +365,7 @@ export class DataTierApplicationWizard {
|
||||
}
|
||||
|
||||
private static async getService(providerName: string): Promise<azdata.DacFxServicesProvider> {
|
||||
let service = azdata.dataprotocol.getProvider<azdata.DacFxServicesProvider>(providerName, azdata.DataProviderType.DacFxServicesProvider);
|
||||
const service = azdata.dataprotocol.getProvider<azdata.DacFxServicesProvider>(providerName, azdata.DataProviderType.DacFxServicesProvider);
|
||||
return service;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -513,8 +513,8 @@ export class SchemaCompareDialog {
|
||||
}
|
||||
}
|
||||
|
||||
protected async getServerValues(isTarget: boolean): Promise<{ connection: azdata.connection.Connection, displayName: string, name: string }[]> {
|
||||
let cons = await azdata.connection.getActiveConnections();
|
||||
protected async getServerValues(isTarget: boolean): Promise<{ connection: azdata.connection.ConnectionProfile, displayName: string, name: string }[]> {
|
||||
let cons = await azdata.connection.getConnections(/* activeConnectionsOnly */ true);
|
||||
// This user has no active connections
|
||||
if (!cons || cons.length === 0) {
|
||||
return undefined;
|
||||
@@ -668,5 +668,5 @@ export class SchemaCompareDialog {
|
||||
}
|
||||
|
||||
interface ConnectionDropdownValue extends azdata.CategoryValue {
|
||||
connection: azdata.connection.Connection;
|
||||
connection: azdata.connection.ConnectionProfile;
|
||||
}
|
||||
@@ -14,6 +14,7 @@ import { getTelemetryErrorType, getEndpointName } from './utils';
|
||||
import { SchemaCompareDialog } from './dialogs/schemaCompareDialog';
|
||||
import { isNullOrUndefined } from 'util';
|
||||
const localize = nls.loadMessageBundle();
|
||||
const msSqlProvider = 'MSSQL';
|
||||
const diffEditorTitle = localize('schemaCompare.CompareDetailsTitle', 'Compare Details');
|
||||
const applyConfirmation = localize('schemaCompare.ApplyConfirmation', 'Are you sure you want to update the target?');
|
||||
const reCompareToRefeshMessage = localize('schemaCompare.RecompareToRefresh', 'Press Compare to refresh the comparison.');
|
||||
@@ -252,7 +253,7 @@ export class SchemaCompareResult {
|
||||
this.deploymentOptions = this.schemaCompareOptionDialog.deploymentOptions;
|
||||
}
|
||||
Telemetry.sendTelemetryEvent('SchemaComparisonStarted');
|
||||
const service = await SchemaCompareResult.getService('MSSQL');
|
||||
const service = await SchemaCompareResult.getService(msSqlProvider);
|
||||
if (!this.operationId) {
|
||||
// create once per page
|
||||
this.operationId = generateGuid();
|
||||
@@ -545,7 +546,7 @@ export class SchemaCompareResult {
|
||||
|
||||
// cancel compare
|
||||
if (this.operationId) {
|
||||
const service = await SchemaCompareResult.getService('MSSQL');
|
||||
const service = await SchemaCompareResult.getService(msSqlProvider);
|
||||
const result = await service.schemaCompareCancel(this.operationId);
|
||||
|
||||
if (!result || !result.success) {
|
||||
@@ -577,7 +578,7 @@ export class SchemaCompareResult {
|
||||
'startTime:': Date.now().toString(),
|
||||
'operationId': this.comparisonResult.operationId
|
||||
});
|
||||
const service = await SchemaCompareResult.getService('MSSQL');
|
||||
const service = await SchemaCompareResult.getService(msSqlProvider);
|
||||
const result = await service.schemaCompareGenerateScript(this.comparisonResult.operationId, this.targetEndpointInfo.serverName, this.targetEndpointInfo.databaseName, azdata.TaskExecutionMode.script);
|
||||
if (!result || !result.success) {
|
||||
Telemetry.sendTelemetryEvent('SchemaCompareGenerateScriptFailed', {
|
||||
@@ -642,7 +643,7 @@ export class SchemaCompareResult {
|
||||
// disable apply and generate script buttons because the results are no longer valid after applying the changes
|
||||
this.setButtonsForRecompare();
|
||||
|
||||
const service = await SchemaCompareResult.getService('MSSQL');
|
||||
const service = await SchemaCompareResult.getService(msSqlProvider);
|
||||
const result = await service.schemaComparePublishChanges(this.comparisonResult.operationId, this.targetEndpointInfo.serverName, this.targetEndpointInfo.databaseName, azdata.TaskExecutionMode.execute);
|
||||
if (!result || !result.success) {
|
||||
Telemetry.sendTelemetryEvent('SchemaCompareApplyFailed', {
|
||||
@@ -777,7 +778,7 @@ export class SchemaCompareResult {
|
||||
|
||||
private async GetDefaultDeploymentOptions(): Promise<void> {
|
||||
// Same as dacfx default options
|
||||
const service = await SchemaCompareResult.getService('MSSQL');
|
||||
const service = await SchemaCompareResult.getService(msSqlProvider);
|
||||
let result = await service.schemaCompareGetDefaultOptions();
|
||||
this.deploymentOptions = result.defaultDeploymentOptions;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user