fix: fix owner ids for default apps

This commit is contained in:
KernelDeimos 2024-07-07 22:35:45 -04:00
parent 10f4d7d50c
commit 283f409a66
2 changed files with 17 additions and 1 deletions

View File

@ -42,7 +42,7 @@ class SqliteDatabaseAccessService extends BaseDatabaseAccessService {
this.db = new Database(this.config.path);
// Database upgrade logic
const TARGET_VERSION = 18;
const TARGET_VERSION = 19;
if ( do_setup ) {
this.log.noticeme(`SETUP: creating database at ${this.config.path}`);
@ -67,6 +67,7 @@ class SqliteDatabaseAccessService extends BaseDatabaseAccessService {
'0018_fix-0003.sql',
'0019_fix-0016.sql',
'0020_dev-center.sql',
'0021_app-owner-id.sql',
].map(p => path_.join(__dirname, 'sqlite_setup', p));
const fs = require('fs');
for ( const filename of sql_files ) {
@ -155,6 +156,10 @@ class SqliteDatabaseAccessService extends BaseDatabaseAccessService {
upgrade_files.push('0020_dev-center.sql');
}
if ( user_version <= 18 ) {
upgrade_files.push('0021_app-owner-id.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}`);

View File

@ -0,0 +1,11 @@
-- fixing owner IDs for default apps;
-- they should all be owned by 'default_user'
UPDATE `apps` SET `owner_user_id`=1 WHERE `uid` IN
(
'app-7870be61-8dff-4a99-af64-e9ae6811e367',
'app-3920851d-bda8-479b-9407-8517293c7d44',
'app-5584fbf7-ed69-41fc-99cd-85da21b1ef51',
'app-11edfba2-1ed3-4e22-8573-47e88fb87d70',
'app-7bdca1a4-6373-4c98-ad97-03ff2d608ca1'
);