mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-14 01:25:37 -05:00
Hook up sql proj publish (#16444)
This commit is contained in:
@@ -39,6 +39,19 @@ import { SqlTargetPlatform } from 'sqldbproj';
|
||||
|
||||
const maxTableLength = 10;
|
||||
|
||||
/**
|
||||
* This is a duplicate of the TaskExecutionMode from azdata.d.ts/vscode-mssql.d.ts, which is needed
|
||||
* for using when running in VS Code since we don't have an actual implementation of the enum at runtime
|
||||
* (unlike azdata which is injected by the extension host). Even specifying it as a const enum in the
|
||||
* typings file currently doesn't work as the TypeScript compiler doesn't currently inline const enum
|
||||
* values imported as "import type" https://github.com/microsoft/TypeScript/issues/40344
|
||||
*/
|
||||
export enum TaskExecutionMode {
|
||||
execute = 0,
|
||||
script = 1,
|
||||
executeAndScript = 2
|
||||
}
|
||||
|
||||
/**
|
||||
* Controller for managing lifecycle of projects
|
||||
*/
|
||||
@@ -252,7 +265,7 @@ export class ProjectsController {
|
||||
|
||||
return publishDatabaseDialog;
|
||||
} else {
|
||||
launchPublishDatabaseQuickpick(project);
|
||||
launchPublishDatabaseQuickpick(project, this);
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
@@ -268,9 +281,7 @@ export class ProjectsController {
|
||||
const telemetryProps: Record<string, string> = {};
|
||||
const telemetryMeasures: Record<string, number> = {};
|
||||
const buildStartTime = new Date().getTime();
|
||||
|
||||
const dacpacPath = await this.buildProject(project);
|
||||
|
||||
const buildEndTime = new Date().getTime();
|
||||
telemetryMeasures.buildDuration = buildEndTime - buildStartTime;
|
||||
telemetryProps.buildSucceeded = (dacpacPath !== '').toString();
|
||||
@@ -287,7 +298,6 @@ export class ProjectsController {
|
||||
// copy dacpac to temp location before publishing
|
||||
const tempPath = path.join(os.tmpdir(), `${path.parse(dacpacPath).name}_${new Date().getTime()}${constants.sqlprojExtension}`);
|
||||
await fs.copyFile(dacpacPath, tempPath);
|
||||
|
||||
const dacFxService = await utils.getDacFxService();
|
||||
|
||||
let result: mssql.DacFxResult;
|
||||
@@ -308,19 +318,19 @@ export class ProjectsController {
|
||||
if (publish) {
|
||||
telemetryProps.publishAction = 'deploy';
|
||||
if (azdataApi) {
|
||||
result = await (dacFxService as mssql.IDacFxService).deployDacpac(tempPath, settings.databaseName, true, settings.connectionUri, azdataApi.TaskExecutionMode.execute, settings.sqlCmdVariables, settings.deploymentOptions);
|
||||
result = await (dacFxService as mssql.IDacFxService).deployDacpac(tempPath, settings.databaseName, true, settings.connectionUri, azdataApi.TaskExecutionMode.execute, settings.sqlCmdVariables, settings.deploymentOptions as mssql.DeploymentOptions);
|
||||
} else {
|
||||
// TODO@chgagnon Fix typing
|
||||
result = await (dacFxService as mssqlVscode.IDacFxService).deployDacpac(tempPath, settings.databaseName, true, settings.connectionUri, <mssqlVscode.TaskExecutionMode><any>azdataApi!.TaskExecutionMode.execute, settings.sqlCmdVariables, <mssqlVscode.DeploymentOptions><any>settings.deploymentOptions);
|
||||
// Have to cast to unknown first to get around compiler error since the mssqlVscode doesn't exist as an actual module at runtime
|
||||
result = await (dacFxService as mssqlVscode.IDacFxService).deployDacpac(tempPath, settings.databaseName, true, settings.connectionUri, TaskExecutionMode.execute as unknown as mssqlVscode.TaskExecutionMode, settings.sqlCmdVariables, settings.deploymentOptions as mssqlVscode.DeploymentOptions);
|
||||
}
|
||||
|
||||
} else {
|
||||
telemetryProps.publishAction = 'generateScript';
|
||||
if (azdataApi) {
|
||||
result = await (dacFxService as mssql.IDacFxService).generateDeployScript(tempPath, settings.databaseName, settings.connectionUri, azdataApi.TaskExecutionMode.script, settings.sqlCmdVariables, settings.deploymentOptions);
|
||||
result = await (dacFxService as mssql.IDacFxService).generateDeployScript(tempPath, settings.databaseName, settings.connectionUri, azdataApi.TaskExecutionMode.script, settings.sqlCmdVariables, settings.deploymentOptions as mssql.DeploymentOptions);
|
||||
} else {
|
||||
// TODO@chgagnon Fix typing
|
||||
result = await (dacFxService as mssqlVscode.IDacFxService).generateDeployScript(tempPath, settings.databaseName, settings.connectionUri, <any>undefined/*mssqlVscode.TaskExecutionMode.script*/, settings.sqlCmdVariables, <mssqlVscode.DeploymentOptions><any>settings.deploymentOptions);
|
||||
// Have to cast to unknown first to get around compiler error since the mssqlVscode doesn't exist as an actual module at runtime
|
||||
result = await (dacFxService as mssqlVscode.IDacFxService).generateDeployScript(tempPath, settings.databaseName, settings.connectionUri, TaskExecutionMode.script as unknown as mssqlVscode.TaskExecutionMode, settings.sqlCmdVariables, settings.deploymentOptions as mssqlVscode.DeploymentOptions);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -337,10 +347,8 @@ export class ProjectsController {
|
||||
const currentPublishIndex = this.publishInfo.findIndex(d => d.startDate === currentPublishTimeInfo);
|
||||
this.publishInfo[currentPublishIndex].status = Status.failed;
|
||||
this.publishInfo[currentPublishIndex].timeToCompleteAction = utils.timeConversion(timeToFailurePublish);
|
||||
|
||||
throw err;
|
||||
}
|
||||
|
||||
const actionEndTime = new Date().getTime();
|
||||
const timeToPublish = actionEndTime - actionStartTime;
|
||||
telemetryProps.actionDuration = timeToPublish.toString();
|
||||
|
||||
Reference in New Issue
Block a user