Skip to content

Commit

Permalink
Update database version when creating a new one
Browse files Browse the repository at this point in the history
  • Loading branch information
KernelDeimos committed Apr 10, 2024
1 parent 0eded34 commit eb66848
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ class SqliteDatabaseAccessService extends BaseDatabaseAccessService {

this.db = new Database(this.config.path);

// Database upgrade logic
const TARGET_VERSION = 1;

if ( do_setup ) {
this.log.noticeme(`SETUP: creating database at ${this.config.path}`);
const sql_files = [
Expand All @@ -55,11 +58,9 @@ class SqliteDatabaseAccessService extends BaseDatabaseAccessService {
const contents = fs.readFileSync(filename, 'utf8');
this.db.exec(contents);
}
await this.db.exec(`PRAGMA user_version = ${TARGET_VERSION};`);
}

// Database upgrade logic
const TARGET_VERSION = 1;

const [{ user_version }] = await this._read('PRAGMA user_version');
this.log.info('database version: ' + user_version);

Expand Down

0 comments on commit eb66848

Please sign in to comment.