Add DW master.dacpac (#15559)

* add DW master.dacpac

* add missing awaits in tests

* use ternary

* only show master in system db dropdown for dw
This commit is contained in:
Kim Santiago
2021-05-27 10:03:33 -07:00
committed by GitHub
parent 3946cee33c
commit faaf667439
5 changed files with 39 additions and 17 deletions

View File

@@ -354,6 +354,9 @@ export const targetPlatformToVersion: Map<string, string> = new Map<string, stri
[sqlDW, 'Dw']
]);
// DW is special since the system dacpac folder has a different name from the target platform
export const AzureDwFolder = 'AzureDw';
export function getTargetPlatformFromVersion(version: string): string {
return Array.from(targetPlatformToVersion.keys()).filter(k => targetPlatformToVersion.get(k) === version)[0];
}

View File

@@ -315,8 +315,8 @@ export class AddDatabaseReferenceDialog {
this.setDefaultDatabaseValues();
});
// only master is a valid system db reference for projects targetting Azure
if (this.project.getProjectTargetVersion().toLowerCase().includes('azure')) {
// only master is a valid system db reference for projects targetting Azure and DW
if (this.project.getProjectTargetVersion().toLowerCase().includes('azure') || this.project.getProjectTargetVersion().toLowerCase().includes('dw')) {
this.systemDatabaseDropdown.values?.splice(1);
}

View File

@@ -441,6 +441,13 @@ export class Project implements ISqlProject {
*/
public async changeTargetPlatform(compatLevel: string): Promise<void> {
if (this.getProjectTargetVersion() !== compatLevel) {
TelemetryReporter.createActionEvent(TelemetryViews.ProjectTree, TelemetryActions.changePlatformType)
.withAdditionalProperties({
from: this.getProjectTargetVersion(),
to: compatLevel
})
.send();
const newDSP = `${constants.MicrosoftDatatoolsSchemaSqlSql}${compatLevel}${constants.databaseSchemaProvider}`;
this.projFileXmlDoc.getElementsByTagName(constants.DSP)[0].childNodes[0].data = newDSP;
this.projFileXmlDoc.getElementsByTagName(constants.DSP)[0].childNodes[0].nodeValue = newDSP;
@@ -462,13 +469,6 @@ export class Project implements ISqlProject {
}
await this.serializeToProjFile(this.projFileXmlDoc);
TelemetryReporter.createActionEvent(TelemetryViews.ProjectTree, TelemetryActions.changePlatformType)
.withAdditionalProperties({
from: this.getProjectTargetVersion(),
to: compatLevel
})
.send();
}
}
@@ -498,13 +498,21 @@ export class Project implements ISqlProject {
}
public getSystemDacpacUri(dacpac: string): Uri {
let version = this.getProjectTargetVersion();
return Uri.parse(path.join('$(NETCoreTargetsPath)', 'SystemDacpacs', version, dacpac));
const versionFolder = this.getSystemDacpacFolderName();
return Uri.parse(path.join('$(NETCoreTargetsPath)', 'SystemDacpacs', versionFolder, dacpac));
}
public getSystemDacpacSsdtUri(dacpac: string): Uri {
let version = this.getProjectTargetVersion();
return Uri.parse(path.join('$(DacPacRootPath)', 'Extensions', 'Microsoft', 'SQLDB', 'Extensions', 'SqlServer', version, 'SqlSchemas', dacpac));
const versionFolder = this.getSystemDacpacFolderName();
return Uri.parse(path.join('$(DacPacRootPath)', 'Extensions', 'Microsoft', 'SQLDB', 'Extensions', 'SqlServer', versionFolder, 'SqlSchemas', dacpac));
}
public getSystemDacpacFolderName(): string {
const version = this.getProjectTargetVersion();
// DW is special because the target version is DW, but the folder name for system dacpacs is AzureDW in SSDT
// the other target versions have the same version name and folder name
return version === constants.targetPlatformToVersion.get(constants.sqlDW) ? constants.AzureDwFolder : version;
}
public getProjectTargetVersion(): string {

View File

@@ -155,17 +155,23 @@ describe('Project: sqlproj content operations', function (): void {
should.equal(uri.fsPath, Uri.parse(path.join('$(NETCoreTargetsPath)', 'SystemDacpacs', '150', constants.masterDacpac)).fsPath);
should.equal(ssdtUri.fsPath, Uri.parse(path.join('$(DacPacRootPath)', 'Extensions', 'Microsoft', 'SQLDB', 'Extensions', 'SqlServer', '150', 'SqlSchemas', constants.masterDacpac)).fsPath);
project.changeTargetPlatform(constants.targetPlatformToVersion.get(constants.sqlServer2016)!);
await project.changeTargetPlatform(constants.targetPlatformToVersion.get(constants.sqlServer2016)!);
uri = project.getSystemDacpacUri(constants.masterDacpac);
ssdtUri = project.getSystemDacpacSsdtUri(constants.masterDacpac);
should.equal(uri.fsPath, Uri.parse(path.join('$(NETCoreTargetsPath)', 'SystemDacpacs', '130', constants.masterDacpac)).fsPath);
should.equal(ssdtUri.fsPath, Uri.parse(path.join('$(DacPacRootPath)', 'Extensions', 'Microsoft', 'SQLDB', 'Extensions', 'SqlServer', '130', 'SqlSchemas', constants.masterDacpac)).fsPath);
project.changeTargetPlatform(constants.targetPlatformToVersion.get(constants.sqlAzure)!);
await project.changeTargetPlatform(constants.targetPlatformToVersion.get(constants.sqlAzure)!);
uri = project.getSystemDacpacUri(constants.masterDacpac);
ssdtUri = project.getSystemDacpacSsdtUri(constants.masterDacpac);
should.equal(uri.fsPath, Uri.parse(path.join('$(NETCoreTargetsPath)', 'SystemDacpacs', 'AzureV12', constants.masterDacpac)).fsPath);
should.equal(ssdtUri.fsPath, Uri.parse(path.join('$(DacPacRootPath)', 'Extensions', 'Microsoft', 'SQLDB', 'Extensions', 'SqlServer', 'AzureV12', 'SqlSchemas', constants.masterDacpac)).fsPath);
await project.changeTargetPlatform(constants.targetPlatformToVersion.get(constants.sqlDW)!);
uri = project.getSystemDacpacUri(constants.masterDacpac);
ssdtUri = project.getSystemDacpacSsdtUri(constants.masterDacpac);
should.equal(uri.fsPath, Uri.parse(path.join('$(NETCoreTargetsPath)', 'SystemDacpacs', 'AzureDw', constants.masterDacpac)).fsPath);
should.equal(ssdtUri.fsPath, Uri.parse(path.join('$(DacPacRootPath)', 'Extensions', 'Microsoft', 'SQLDB', 'Extensions', 'SqlServer', 'AzureDw', 'SqlSchemas', constants.masterDacpac)).fsPath);
});
@@ -192,6 +198,11 @@ describe('Project: sqlproj content operations', function (): void {
projFileText = await fs.readFile(projFilePath);
should(projFileText.includes(convertSlashesForSqlProj(Uri.file(path.join('$(NETCoreTargetsPath)', 'SystemDacpacs', 'AzureV12', constants.masterDacpac)).fsPath.substring(1)))).be.true('System db reference path should have been updated to AzureV12');
should(projFileText.includes(convertSlashesForSqlProj(Uri.file(path.join('$(DacPacRootPath)', 'Extensions', 'Microsoft', 'SQLDB', 'Extensions', 'SqlServer', 'AzureV12', 'SqlSchemas', constants.masterDacpac)).fsPath.substring(1)))).be.true('System db SSDT reference path should be AzureV12');
await project.changeTargetPlatform(constants.targetPlatformToVersion.get(constants.sqlDW)!);
projFileText = await fs.readFile(projFilePath);
should(projFileText.includes(convertSlashesForSqlProj(Uri.file(path.join('$(NETCoreTargetsPath)', 'SystemDacpacs', 'AzureDw', constants.masterDacpac)).fsPath.substring(1)))).be.true('System db reference path should have been updated to AzureDw');
should(projFileText.includes(convertSlashesForSqlProj(Uri.file(path.join('$(DacPacRootPath)', 'Extensions', 'Microsoft', 'SQLDB', 'Extensions', 'SqlServer', 'AzureDw', 'SqlSchemas', constants.masterDacpac)).fsPath.substring(1)))).be.true('System db SSDT reference path should be AzureDw');
});
it('Should choose correct msdb dacpac', async function (): Promise<void> {
@@ -203,7 +214,7 @@ describe('Project: sqlproj content operations', function (): void {
should.equal(uri.fsPath, Uri.parse(path.join('$(NETCoreTargetsPath)', 'SystemDacpacs', '150', constants.msdbDacpac)).fsPath);
should.equal(ssdtUri.fsPath, Uri.parse(path.join('$(DacPacRootPath)', 'Extensions', 'Microsoft', 'SQLDB', 'Extensions', 'SqlServer', '150', 'SqlSchemas', constants.msdbDacpac)).fsPath);
project.changeTargetPlatform(constants.targetPlatformToVersion.get(constants.sqlServer2016)!);
await project.changeTargetPlatform(constants.targetPlatformToVersion.get(constants.sqlServer2016)!);
uri = project.getSystemDacpacUri(constants.msdbDacpac);
ssdtUri = project.getSystemDacpacSsdtUri(constants.msdbDacpac);
should.equal(uri.fsPath, Uri.parse(path.join('$(NETCoreTargetsPath)', 'SystemDacpacs', '130', constants.msdbDacpac)).fsPath);
@@ -214,7 +225,7 @@ describe('Project: sqlproj content operations', function (): void {
projFilePath = await testUtils.createTestSqlProjFile(baselines.newProjectFileBaseline);
const project = await Project.openProject(projFilePath);
project.changeTargetPlatform('invalidPlatform');
await project.changeTargetPlatform('invalidPlatform');
await testUtils.shouldThrowSpecificError(async () => await project.getSystemDacpacUri(constants.masterDacpac), constants.invalidDataSchemaProvider);
});