mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Apply changes from remote database to sqlproj - schema-compare changes (#17679)
* update project from database * update project from database * Merge from main * Removing dupe test stub * PR feedback * cleanup * PR feedback * Fixing tests, adding stubs to update sqlproj as schema compare target * updating code comment Co-authored-by: Noureldine Yehia <t-nyehia@microsoft.com>
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
import type * as azdataType from 'azdata'; // eslint-disable-line no-duplicate-imports
|
||||
import * as vscode from 'vscode';
|
||||
import * as mssql from '../../mssql';
|
||||
import * as os from 'os';
|
||||
@@ -39,6 +40,19 @@ export function getTelemetryErrorType(msg: string): string {
|
||||
}
|
||||
}
|
||||
|
||||
export function getSchemaCompareEndpointString(endpointType: mssql.SchemaCompareEndpointType): string {
|
||||
switch (endpointType) {
|
||||
case mssql.SchemaCompareEndpointType.Database:
|
||||
return 'Database';
|
||||
case mssql.SchemaCompareEndpointType.Dacpac:
|
||||
return 'Dacpac';
|
||||
case mssql.SchemaCompareEndpointType.Project:
|
||||
return 'Project';
|
||||
default:
|
||||
return `Unknown: ${endpointType}`;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the appropriate endpoint name depending on if the endpoint is a dacpac or a database
|
||||
* @param endpoint endpoint to get the name of
|
||||
@@ -64,8 +78,11 @@ export function getEndpointName(endpoint: mssql.SchemaCompareEndpointInfo): stri
|
||||
return ' ';
|
||||
}
|
||||
|
||||
} else {
|
||||
} else if (endpoint.endpointType === mssql.SchemaCompareEndpointType.Dacpac) {
|
||||
return endpoint.packageFilePath;
|
||||
|
||||
} else {
|
||||
return endpoint.projectFilePath;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,3 +161,24 @@ export async function exists(path: string): Promise<boolean> {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Try to load the azdata API - but gracefully handle the failure in case we're running
|
||||
// in a context where the API doesn't exist (such as VS Code)
|
||||
let azdataApi: typeof azdataType | undefined = undefined;
|
||||
try {
|
||||
azdataApi = require('azdata');
|
||||
if (!azdataApi?.version) {
|
||||
// webpacking makes the require return an empty object instead of throwing an error so make sure we clear the var
|
||||
azdataApi = undefined;
|
||||
}
|
||||
} catch {
|
||||
// no-op
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the azdata API if it's available in the context this extension is running in.
|
||||
* @returns The azdata API if it's available
|
||||
*/
|
||||
export function getAzdataApi(): typeof azdataType | undefined {
|
||||
return azdataApi;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user