Skip to content

Commit 8eaeefb

Browse files
alexetaeisenberg
authored andcommitted
Use single file upgrades where possible.
1 parent 49ac979 commit 8eaeefb

2 files changed

Lines changed: 50 additions & 4 deletions

File tree

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

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,11 @@ export interface CompileUpgradeParams {
406406
* A directory to store parts of the compiled upgrade
407407
*/
408408
upgradeTempDir: string;
409+
/**
410+
* Enable single file upgrades, set to true to allow
411+
* using single file upgrades.
412+
*/
413+
singleFileUpgrades?: boolean;
409414
}
410415

411416
/**
@@ -492,10 +497,14 @@ export interface UpgradeDescription {
492497
newSha: string;
493498
}
494499

500+
501+
export type CompiledUpgrades = MultiFileCompiledUpgrades | SingleFileCompiledUpgrade
502+
495503
/**
496-
* A compiled upgrade.
504+
* A compiled upgrade.
505+
* The upgrade is spread among multiple files.
497506
*/
498-
export interface CompiledUpgrades {
507+
export interface MultiFileCompiledUpgrades {
499508
/**
500509
* The initial sha of the dbscheme to upgrade from
501510
*/
@@ -504,10 +513,42 @@ export interface CompiledUpgrades {
504513
* The path to the new dataset statistics
505514
*/
506515
newStatsPath: string;
516+
/**
517+
* The path to the new dataset dbscheme
518+
*/
519+
newDbscheme: string;
507520
/**
508521
* The steps in the upgrade path
509522
*/
510523
scripts: CompiledUpgradeScript[];
524+
/**
525+
* Will never exist in an old result
526+
*/
527+
compiledUpgradeFile?: never;
528+
/**
529+
* The sha of the target dataset.
530+
*/
531+
targetSha: string;
532+
}
533+
534+
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;
544+
/**
545+
* The steps in the upgrade path
546+
*/
547+
descriptions: UpgradeDescription[];
548+
/**
549+
* The file containing the upgrade
550+
*/
551+
compiledUpgradeFile: string;
511552
/**
512553
* The sha of the target dataset.
513554
*/

extensions/ql-vscode/src/upgrades.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,11 @@ export async function upgradeDatabase(
157157

158158
try {
159159
qs.logger.log('Running the following database upgrade:');
160-
qs.logger.log(compileUpgradeResult.compiledUpgrades.scripts.map(s => s.description.description).join('\n'));
160+
if (compileUpgradeResult.compiledUpgrades.compiledUpgradeFile === undefined) {
161+
qs.logger.log(compileUpgradeResult.compiledUpgrades.scripts.map(s => s.description.description).join('\n'));
162+
} else {
163+
qs.logger.log(compileUpgradeResult.compiledUpgrades.descriptions.map(s => s.description).join('\n'));
164+
}
161165
return await runDatabaseUpgrade(qs, db, compileUpgradeResult.compiledUpgrades, progress, token);
162166
}
163167
catch (e) {
@@ -192,7 +196,8 @@ async function compileDatabaseUpgrade(
192196
): Promise<messages.CompileUpgradeResult> {
193197
const params: messages.CompileUpgradeParams = {
194198
upgrade: upgradeParams,
195-
upgradeTempDir: upgradesTmpDir.name
199+
upgradeTempDir: upgradesTmpDir.name,
200+
singleFileUpgrades: true
196201
};
197202

198203
progress({

0 commit comments

Comments
 (0)