mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
fix system db references going away when project target platform is changed (#14255)
* fix system db references going away when target platform is changed * bump version
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
"name": "sql-database-projects",
|
"name": "sql-database-projects",
|
||||||
"displayName": "SQL Database Projects",
|
"displayName": "SQL Database Projects",
|
||||||
"description": "The SQL Database Projects extension for Azure Data Studio allows users to develop and publish database schemas.",
|
"description": "The SQL Database Projects extension for Azure Data Studio allows users to develop and publish database schemas.",
|
||||||
"version": "0.6.0",
|
"version": "0.6.1",
|
||||||
"publisher": "Microsoft",
|
"publisher": "Microsoft",
|
||||||
"preview": true,
|
"preview": true,
|
||||||
"engines": {
|
"engines": {
|
||||||
|
|||||||
@@ -376,7 +376,7 @@ export class Project {
|
|||||||
// update any system db references
|
// update any system db references
|
||||||
const systemDbReferences = this.databaseReferences.filter(r => r instanceof SystemDatabaseReferenceProjectEntry) as SystemDatabaseReferenceProjectEntry[];
|
const systemDbReferences = this.databaseReferences.filter(r => r instanceof SystemDatabaseReferenceProjectEntry) as SystemDatabaseReferenceProjectEntry[];
|
||||||
if (systemDbReferences.length > 0) {
|
if (systemDbReferences.length > 0) {
|
||||||
systemDbReferences.forEach((r) => {
|
for (let r of systemDbReferences) {
|
||||||
// remove old entry in sqlproj
|
// remove old entry in sqlproj
|
||||||
this.removeDatabaseReferenceFromProjFile(r);
|
this.removeDatabaseReferenceFromProjFile(r);
|
||||||
|
|
||||||
@@ -385,8 +385,8 @@ export class Project {
|
|||||||
r.ssdtUri = this.getSystemDacpacSsdtUri(`${r.databaseName}.dacpac`);
|
r.ssdtUri = this.getSystemDacpacSsdtUri(`${r.databaseName}.dacpac`);
|
||||||
|
|
||||||
// add updated system db reference to sqlproj
|
// add updated system db reference to sqlproj
|
||||||
this.addDatabaseReferenceToProjFile(r);
|
await this.addDatabaseReferenceToProjFile(r);
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.serializeToProjFile(this.projFileXmlDoc);
|
await this.serializeToProjFile(this.projFileXmlDoc);
|
||||||
|
|||||||
@@ -168,6 +168,32 @@ describe('Project: sqlproj content operations', function (): void {
|
|||||||
should.equal(ssdtUri.fsPath, Uri.parse(path.join('$(DacPacRootPath)', 'Extensions', 'Microsoft', 'SQLDB', 'Extensions', 'SqlServer', 'AzureV12', 'SqlSchemas', constants.masterDacpac)).fsPath);
|
should.equal(ssdtUri.fsPath, Uri.parse(path.join('$(DacPacRootPath)', 'Extensions', 'Microsoft', 'SQLDB', 'Extensions', 'SqlServer', 'AzureV12', 'SqlSchemas', constants.masterDacpac)).fsPath);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
it('Should update system dacpac paths in sqlproj when target platform is changed', async function (): Promise<void> {
|
||||||
|
projFilePath = await testUtils.createTestSqlProjFile(baselines.newProjectFileBaseline);
|
||||||
|
const project = await Project.openProject(projFilePath);
|
||||||
|
await project.addSystemDatabaseReference({
|
||||||
|
systemDb: SystemDatabase.master,
|
||||||
|
suppressMissingDependenciesErrors: false
|
||||||
|
});
|
||||||
|
|
||||||
|
let projFileText = await fs.readFile(projFilePath);
|
||||||
|
|
||||||
|
should.equal(project.databaseReferences.length, 1, 'System db reference should have been added');
|
||||||
|
should(projFileText.includes(convertSlashesForSqlProj(Uri.file(path.join('$(NETCoreTargetsPath)', 'SystemDacpacs', '150', constants.masterDacpac)).fsPath.substring(1)))).be.true('System db reference path should be 150');
|
||||||
|
should(projFileText.includes(convertSlashesForSqlProj(Uri.file(path.join('$(DacPacRootPath)', 'Extensions', 'Microsoft', 'SQLDB', 'Extensions', 'SqlServer', '150', 'SqlSchemas', constants.masterDacpac)).fsPath.substring(1)))).be.true('System db SSDT reference path should be 150');
|
||||||
|
|
||||||
|
await project.changeTargetPlatform(constants.targetPlatformToVersion.get(constants.sqlServer2016)!);
|
||||||
|
projFileText = await fs.readFile(projFilePath);
|
||||||
|
should(projFileText.includes(convertSlashesForSqlProj(Uri.file(path.join('$(NETCoreTargetsPath)', 'SystemDacpacs', '130', constants.masterDacpac)).fsPath.substring(1)))).be.true('System db reference path should have been updated to 130');
|
||||||
|
should(projFileText.includes(convertSlashesForSqlProj(Uri.file(path.join('$(DacPacRootPath)', 'Extensions', 'Microsoft', 'SQLDB', 'Extensions', 'SqlServer', '130', 'SqlSchemas', constants.masterDacpac)).fsPath.substring(1)))).be.true('System db SSDT reference path should be 130');
|
||||||
|
|
||||||
|
await project.changeTargetPlatform(constants.targetPlatformToVersion.get(constants.sqlAzure)!);
|
||||||
|
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');
|
||||||
|
});
|
||||||
|
|
||||||
it('Should choose correct msdb dacpac', async function (): Promise<void> {
|
it('Should choose correct msdb dacpac', async function (): Promise<void> {
|
||||||
projFilePath = await testUtils.createTestSqlProjFile(baselines.newProjectFileBaseline);
|
projFilePath = await testUtils.createTestSqlProjFile(baselines.newProjectFileBaseline);
|
||||||
const project = await Project.openProject(projFilePath);
|
const project = await Project.openProject(projFilePath);
|
||||||
@@ -182,12 +208,6 @@ describe('Project: sqlproj content operations', function (): void {
|
|||||||
ssdtUri = project.getSystemDacpacSsdtUri(constants.msdbDacpac);
|
ssdtUri = project.getSystemDacpacSsdtUri(constants.msdbDacpac);
|
||||||
should.equal(uri.fsPath, Uri.parse(path.join('$(NETCoreTargetsPath)', 'SystemDacpacs', '130', constants.msdbDacpac)).fsPath);
|
should.equal(uri.fsPath, Uri.parse(path.join('$(NETCoreTargetsPath)', 'SystemDacpacs', '130', constants.msdbDacpac)).fsPath);
|
||||||
should.equal(ssdtUri.fsPath, Uri.parse(path.join('$(DacPacRootPath)', 'Extensions', 'Microsoft', 'SQLDB', 'Extensions', 'SqlServer', '130', 'SqlSchemas', constants.msdbDacpac)).fsPath);
|
should.equal(ssdtUri.fsPath, Uri.parse(path.join('$(DacPacRootPath)', 'Extensions', 'Microsoft', 'SQLDB', 'Extensions', 'SqlServer', '130', 'SqlSchemas', constants.msdbDacpac)).fsPath);
|
||||||
|
|
||||||
project.changeTargetPlatform(constants.targetPlatformToVersion.get(constants.sqlAzure)!);
|
|
||||||
uri = project.getSystemDacpacUri(constants.msdbDacpac);
|
|
||||||
ssdtUri = project.getSystemDacpacSsdtUri(constants.msdbDacpac);
|
|
||||||
should.equal(uri.fsPath, Uri.parse(path.join('$(NETCoreTargetsPath)', 'SystemDacpacs', 'AzureV12', constants.msdbDacpac)).fsPath);
|
|
||||||
should.equal(ssdtUri.fsPath, Uri.parse(path.join('$(DacPacRootPath)', 'Extensions', 'Microsoft', 'SQLDB', 'Extensions', 'SqlServer', 'AzureV12', 'SqlSchemas', constants.msdbDacpac)).fsPath);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Should throw error when choosing correct master dacpac if invalid DSP', async function (): Promise<void> {
|
it('Should throw error when choosing correct master dacpac if invalid DSP', async function (): Promise<void> {
|
||||||
|
|||||||
Reference in New Issue
Block a user