@shopify/shopify-app-session-storage
Version:
Shopify App Session Storage - abstract class
33 lines (30 loc) • 1.06 kB
JavaScript
import { defaultSessionStorageMigratorOptions } from './types.mjs';
class AbstractMigrationEngine {
options;
connection;
ready;
migrations;
constructor(db, opts = {}, migrations) {
this.options = { ...defaultSessionStorageMigratorOptions, ...opts };
this.connection = db;
this.migrations = migrations;
this.ready = this.initMigrationPersistence();
}
async applyMigrations(databaseReady) {
await databaseReady;
await this.ready;
for (const { migrationName, migrationFunction } of this.getMigrationList()) {
const migrationApplied = await this.hasMigrationBeenApplied(migrationName);
if (!migrationApplied) {
await migrationFunction(this.connection);
await this.saveAppliedMigration(migrationName);
}
}
return Promise.resolve();
}
getMigrationList() {
return this.migrations;
}
}
export { AbstractMigrationEngine };
//# sourceMappingURL=abstract-migration-engine.mjs.map