db: add protected flag to app and subdomain

This commit is contained in:
KernelDeimos 2024-06-18 22:06:36 -04:00 committed by Eric Dubé
parent 360ad2e252
commit 56e527d3ee
4 changed files with 14 additions and 1 deletions

View File

@ -117,6 +117,9 @@ module.exports = {
to: 'app', to: 'app',
sql: { use_id: true }, sql: { use_id: true },
}, },
protected: {
type: 'flag',
},
// OPERATIONS // OPERATIONS
last_review: { last_review: {

View File

@ -94,6 +94,9 @@ module.exports = {
to: 'app', to: 'app',
sql: { use_id: true }, sql: { use_id: true },
}, },
protected: {
type: 'flag',
},
} }
}; };

View File

@ -42,7 +42,7 @@ class SqliteDatabaseAccessService extends BaseDatabaseAccessService {
this.db = new Database(this.config.path); this.db = new Database(this.config.path);
// Database upgrade logic // Database upgrade logic
const TARGET_VERSION = 10; const TARGET_VERSION = 11;
if ( do_setup ) { if ( do_setup ) {
this.log.noticeme(`SETUP: creating database at ${this.config.path}`); this.log.noticeme(`SETUP: creating database at ${this.config.path}`);
@ -59,6 +59,7 @@ class SqliteDatabaseAccessService extends BaseDatabaseAccessService {
'0010_add-git-app.sql', '0010_add-git-app.sql',
'0011_notification.sql', '0011_notification.sql',
'0012_appmetadata.sql', '0012_appmetadata.sql',
'0013_protected-apps.sql',
].map(p => path_.join(__dirname, 'sqlite_setup', p)); ].map(p => path_.join(__dirname, 'sqlite_setup', p));
const fs = require('fs'); const fs = require('fs');
for ( const filename of sql_files ) { for ( const filename of sql_files ) {
@ -115,6 +116,10 @@ class SqliteDatabaseAccessService extends BaseDatabaseAccessService {
upgrade_files.push('0012_appmetadata.sql'); upgrade_files.push('0012_appmetadata.sql');
} }
if ( user_version <= 10 ) {
upgrade_files.push('0013_protected-apps.sql');
}
if ( upgrade_files.length > 0 ) { if ( upgrade_files.length > 0 ) {
this.log.noticeme(`Database out of date: ${this.config.path}`); this.log.noticeme(`Database out of date: ${this.config.path}`);
this.log.noticeme(`UPGRADING DATABASE: ${user_version} -> ${TARGET_VERSION}`); this.log.noticeme(`UPGRADING DATABASE: ${user_version} -> ${TARGET_VERSION}`);

View File

@ -0,0 +1,2 @@
ALTER TABLE apps ADD COLUMN "protected" tinyint(1) DEFAULT '0';
ALTER TABLE subdomains ADD COLUMN "protected" tinyint(1) DEFAULT '0';