diff --git a/extensions/sql-database-projects/src/dialogs/publishDatabaseQuickpick.ts b/extensions/sql-database-projects/src/dialogs/publishDatabaseQuickpick.ts index 5c55bca81f..d4334e7c66 100644 --- a/extensions/sql-database-projects/src/dialogs/publishDatabaseQuickpick.ts +++ b/extensions/sql-database-projects/src/dialogs/publishDatabaseQuickpick.ts @@ -9,6 +9,7 @@ import { Project } from '../models/project'; import { PublishProfile, readPublishProfile } from '../models/publishProfile/publishProfile'; import { promptForPublishProfile } from './publishDatabaseDialog'; import { getVscodeMssqlApi } from '../common/utils'; +import { IConnectionInfo } from 'vscode-mssql'; /** * Create flow for Publishing a database using only VS Code-native APIs such as QuickPick @@ -72,15 +73,19 @@ export async function launchPublishDatabaseQuickpick(project: Project): Promise< // 2. Select connection const vscodeMssqlApi = await getVscodeMssqlApi(); + let connectionProfile: IConnectionInfo | undefined = undefined; + let connectionUri: string = ''; let dbs: string[] | undefined = undefined; while (!dbs) { - const connectionProfile = await vscodeMssqlApi.promptForConnection(true); + connectionProfile = await vscodeMssqlApi.promptForConnection(true); if (!connectionProfile) { + // User cancelled return; } // Get the list of databases now to validate that the connection is valid and re-prompt them if it isn't try { - dbs = await vscodeMssqlApi.listDatabases(connectionProfile); + connectionUri = await vscodeMssqlApi.connect(connectionProfile); + dbs = await vscodeMssqlApi.listDatabases(connectionUri); } catch (err) { // no-op, the mssql extension handles showing the error to the user. We'll just go // back and prompt the user for a connection again diff --git a/extensions/sql-database-projects/src/typings/vscode-mssql.d.ts b/extensions/sql-database-projects/src/typings/vscode-mssql.d.ts index 94ec4fe523..66349feb05 100644 --- a/extensions/sql-database-projects/src/typings/vscode-mssql.d.ts +++ b/extensions/sql-database-projects/src/typings/vscode-mssql.d.ts @@ -26,6 +26,11 @@ declare module 'vscode-mssql' { */ readonly dacFx: IDacFxService; + /** + * Service for accessing SchemaCompare functionality + */ + readonly schemaCompare: ISchemaCompareService; + /** * Prompts the user to select an existing connection or create a new one, and then returns the result * @param ignoreFocusOut Whether the quickpick prompt ignores focus out (default false) @@ -33,11 +38,19 @@ declare module 'vscode-mssql' { promptForConnection(ignoreFocusOut?: boolean): Promise; /** - * Lists the databases for a given connection. An error is thrown and displayed to the user if an - * error occurs while connecting - * @param connection The connection to list the databases for + * Attempts to create a new connection for the given connection info. An error is thrown and displayed + * to the user if an error occurs while connecting. + * @param connectionInfo The connection info + * @returns The URI associated with this connection */ - listDatabases(connection: IConnectionInfo): Promise; + connect(connectionInfo: IConnectionInfo): Promise; + + /** + * Lists the databases for a given connection. Must be given an already-opened connection to succeed. + * @param connectionUri The URI of the connection to list the databases for. + * @returns The list of database names + */ + listDatabases(connectionUri: string): Promise; } /** @@ -212,6 +225,10 @@ declare module 'vscode-mssql' { schemaObjectType = 5 } + export interface ISchemaCompareService { + schemaCompareGetDefaultOptions(): Thenable; + } + export interface IDacFxService { exportBacpac(databaseName: string, packageFilePath: string, ownerUri: string, taskExecutionMode: TaskExecutionMode): Thenable; importBacpac(packageFilePath: string, databaseName: string, ownerUri: string, taskExecutionMode: TaskExecutionMode): Thenable; @@ -467,4 +484,10 @@ declare module 'vscode-mssql' { createStreamingJobTsql: string; } + export interface SchemaCompareGetOptionsParams { } + + export interface SchemaCompareOptionsResult extends ResultStatus { + defaultDeploymentOptions: DeploymentOptions; + } + }