Skip to content

Commit 402700f

Browse files
alexetaeisenberg
authored andcommitted
SingleFileUpgrades: Address comments
1 parent 8eaeefb commit 402700f

2 files changed

Lines changed: 23 additions & 21 deletions

File tree

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

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -501,10 +501,9 @@ export interface UpgradeDescription {
501501
export type CompiledUpgrades = MultiFileCompiledUpgrades | SingleFileCompiledUpgrade
502502

503503
/**
504-
* A compiled upgrade.
505-
* The upgrade is spread among multiple files.
504+
* The parts shared by all compiled upgrades
506505
*/
507-
export interface MultiFileCompiledUpgrades {
506+
interface CompiledUpgradesBase {
508507
/**
509508
* The initial sha of the dbscheme to upgrade from
510509
*/
@@ -513,6 +512,18 @@ export interface MultiFileCompiledUpgrades {
513512
* The path to the new dataset statistics
514513
*/
515514
newStatsPath: string;
515+
/**
516+
* The sha of the target dataset.
517+
*/
518+
targetSha: string;
519+
}
520+
521+
522+
/**
523+
* A compiled upgrade.
524+
* The upgrade is spread among multiple files.
525+
*/
526+
interface MultiFileCompiledUpgrades extends CompiledUpgradesBase {
516527
/**
517528
* The path to the new dataset dbscheme
518529
*/
@@ -525,34 +536,22 @@ export interface MultiFileCompiledUpgrades {
525536
* Will never exist in an old result
526537
*/
527538
compiledUpgradeFile?: never;
528-
/**
529-
* The sha of the target dataset.
530-
*/
531-
targetSha: string;
532539
}
533540

534541

535-
export interface SingleFileCompiledUpgrade {
536-
/**
537-
* The initial sha of the dbscheme to upgrade from
538-
*/
539-
initialSha: string;
540-
/**
541-
* The path to the new dataset statistics
542-
*/
543-
newStatsPath: string;
542+
/**
543+
* A compiled upgrade.
544+
* The upgrade is in a single file.
545+
*/
546+
export interface SingleFileCompiledUpgrade extends CompiledUpgradesBase {
544547
/**
545548
* The steps in the upgrade path
546549
*/
547550
descriptions: UpgradeDescription[];
548551
/**
549-
* The file containing the upgrade
552+
* A path to a file containing the upgrade
550553
*/
551554
compiledUpgradeFile: string;
552-
/**
553-
* The sha of the target dataset.
554-
*/
555-
targetSha: string;
556555
}
557556

558557
/**

extensions/ql-vscode/src/upgrades.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ export async function upgradeDatabase(
157157

158158
try {
159159
qs.logger.log('Running the following database upgrade:');
160+
// We use the presence of compiledUpgradeFile to check
161+
// if it is multifile or not. We need to explicitly check undefined
162+
// as the types claim the empty string is a valid value
160163
if (compileUpgradeResult.compiledUpgrades.compiledUpgradeFile === undefined) {
161164
qs.logger.log(compileUpgradeResult.compiledUpgrades.scripts.map(s => s.description.description).join('\n'));
162165
} else {

0 commit comments

Comments
 (0)