mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-18 01:25:37 -05:00
Set target platform for database project from the server metadata (#20558)
* Set target platform for database project from the server metadata * Addressed comments
This commit is contained in:
@@ -594,6 +594,15 @@ export const targetPlatformToVersion: Map<string, string> = new Map<string, stri
|
||||
[SqlTargetPlatform.sqlDW, 'Dw']
|
||||
]);
|
||||
|
||||
export const onPremServerVersionToTargetPlatform: Map<number, SqlTargetPlatform> = new Map<number, SqlTargetPlatform>([
|
||||
[11, SqlTargetPlatform.sqlServer2012],
|
||||
[12, SqlTargetPlatform.sqlServer2014],
|
||||
[13, SqlTargetPlatform.sqlServer2016],
|
||||
[14, SqlTargetPlatform.sqlServer2017],
|
||||
[15, SqlTargetPlatform.sqlServer2019],
|
||||
[16, SqlTargetPlatform.sqlServer2022]
|
||||
]);
|
||||
|
||||
// DW is special since the system dacpac folder has a different name from the target platform
|
||||
export const AzureDwFolder = 'AzureDw';
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import * as vscodeMssql from 'vscode-mssql';
|
||||
import * as fse from 'fs-extra';
|
||||
import * as which from 'which';
|
||||
import { promises as fs } from 'fs';
|
||||
import { ISqlProject } from 'sqldbproj';
|
||||
import { ISqlProject, SqlTargetPlatform } from 'sqldbproj';
|
||||
|
||||
export interface ValidationResult {
|
||||
errorMessage: string;
|
||||
@@ -711,3 +711,24 @@ export async function fileContainsCreateTableStatement(fullPath: string, project
|
||||
|
||||
return containsCreateTableStatement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets target platform based on the server edition/version
|
||||
* @param connectionId server connection profile id
|
||||
* @returns target platform for the database project
|
||||
*/
|
||||
export async function getTargetPlatformFromServerVersion(connectionId: string): Promise<SqlTargetPlatform | undefined> {
|
||||
const serverInfo = await getAzdataApi()!.connection.getServerInfo(connectionId);
|
||||
const isCloud = serverInfo.isCloud;
|
||||
|
||||
let targetPlatform;
|
||||
if (isCloud) {
|
||||
const engineEdition = serverInfo.engineEditionId;
|
||||
targetPlatform = engineEdition === getAzdataApi()!.DatabaseEngineEdition.SqlDataWarehouse ? SqlTargetPlatform.sqlDW : SqlTargetPlatform.sqlAzure;
|
||||
} else {
|
||||
const serverMajorVersion = serverInfo.serverMajorVersion;
|
||||
targetPlatform = serverMajorVersion ? constants.onPremServerVersionToTargetPlatform.get(serverMajorVersion) : undefined;
|
||||
}
|
||||
|
||||
return targetPlatform;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user