Skip to content

Commit

Permalink
fix: database migration
Browse files Browse the repository at this point in the history
  • Loading branch information
KernelDeimos committed Jun 16, 2024
1 parent 6d1c1d3 commit 9b39309
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class SqliteDatabaseAccessService extends BaseDatabaseAccessService {
this.db = new Database(this.config.path);

// Database upgrade logic
const TARGET_VERSION = 9;
const TARGET_VERSION = 10;

if ( do_setup ) {
this.log.noticeme(`SETUP: creating database at ${this.config.path}`);
Expand All @@ -57,6 +57,8 @@ class SqliteDatabaseAccessService extends BaseDatabaseAccessService {
'0008_otp.sql',
'0009_app-prefix-fix.sql',
'0010_add-git-app.sql',
'0011_notification.sql',
'0012_appmetadata.sql',
].map(p => path_.join(__dirname, 'sqlite_setup', p));
const fs = require('fs');
for ( const filename of sql_files ) {
Expand Down Expand Up @@ -109,6 +111,10 @@ class SqliteDatabaseAccessService extends BaseDatabaseAccessService {
upgrade_files.push('0011_notification.sql');
}

if ( user_version <= 9 ) {
upgrade_files.push('0012_appmetadata.sql');
}

if ( upgrade_files.length > 0 ) {
this.log.noticeme(`Database out of date: ${this.config.path}`);
this.log.noticeme(`UPGRADING DATABASE: ${user_version} -> ${TARGET_VERSION}`);
Expand Down

0 comments on commit 9b39309

Please sign in to comment.