Skip to content

Commit 70ddbd0

Browse files
alexetaeisenberg
authored andcommitted
Adress comments on non-destructive upgrades.
1 parent ace92a4 commit 70ddbd0

3 files changed

Lines changed: 7 additions & 5 deletions

File tree

extensions/ql-vscode/src/cli.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,7 @@ export class CodeQLCliServer implements Disposable {
651651
* Gets information necessary for upgrading a database.
652652
* @param dbScheme the path to the dbscheme of the database to be upgraded.
653653
* @param searchPath A list of directories to search for upgrade scripts.
654+
* @param targetDbScheme The dbscheme to try to upgrade to.
654655
* @returns A list of database upgrade script directories
655656
*/
656657
resolveUpgrades(dbScheme: string, searchPath: string[], targetDbScheme?: string): Promise<UpgradesInfo> {

extensions/ql-vscode/src/pure/messages.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ export interface CompileUpgradeParams {
418418
*/
419419
export interface CompileUpgradeSequenceParams {
420420
/**
421-
* The sequence of upogrades to compile
421+
* The sequence of upgrades to compile
422422
*/
423423
upgradePaths: string[];
424424
/**

extensions/ql-vscode/src/upgrades.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,9 @@ const MAX_UPGRADE_MESSAGE_LINES = 10;
2323
*
2424
* This requires 3 features. The ability to compile an upgrade sequence; The ability to
2525
* run a non-destructive upgrades as a query; the ability to specify a target when
26-
* resolving upgrades.
26+
* resolving upgrades. We check for a version of codeql that has all three features.
2727
*/
2828
export async function hasNondestructiveUpgradeCapabilities(qs: qsClient.QueryServerClient): Promise<boolean> {
29-
// TODO change to actual version when known
30-
// Note it is probably something 2.4.something
3129
return semver.gte(await qs.cliServer.getVersion(), '2.4.1');
3230
}
3331

@@ -46,6 +44,9 @@ export async function compileDatabaseUpgradeSequence(qs: qsClient.QueryServerCli
4644
if (db.contents === undefined || db.contents.dbSchemeUri === undefined) {
4745
throw new Error('Database is invalid, and cannot be upgraded.');
4846
}
47+
if (!hasNondestructiveUpgradeCapabilities(qs)) {
48+
throw new Error('The version of codeql is to old to run non-destructive upgrades.');
49+
}
4950
// If possible just compile the upgrade sequence
5051
return await qs.sendRequest(messages.compileUpgradeSequence, {
5152
upgradeTempDir: currentUpgradeTmp.name,
@@ -72,7 +73,7 @@ async function compileDatabaseUpgrade(
7273
}
7374
// We have the upgrades we want but compileUpgrade
7475
// requires searching for them. So we use the parent directories of the upgrades
75-
// as the uograde path.
76+
// as the upgrade path.
7677
const parentDirs = resolvedSequence.map(dir => path.dirname(dir));
7778
const uniqueParentDirs = new Set(parentDirs);
7879
progress({

0 commit comments

Comments
 (0)