update old sub account rows to use new column on start

archive-and-sub-as-columns
Moe 2022-02-16 22:04:44 -08:00
parent e853b5da1b
commit a0ff02282e
1 changed files with 11 additions and 3 deletions

View File

@ -200,9 +200,17 @@ module.exports = function(s,config){
table.tinyint('subAccount',1).defaultTo(0)
}).then(() => {
s.systemLog('Created new columns in Users table : subAccount');
s.databaseEngine('Users')
.update({'subAccount': '1'})
.where('details', 'like', '%"sub":"1"%');
s.systemLog('Updating Sub-Acccounts to use new column');
s.knexQuery({
action: "update",
table: "Users",
update: {
subAccount: 1
},
where: [
['details', 'LIKE', '%"sub"%'],
]
});
}).catch((err) => {
if(err && err.code !== 'ER_DUP_FIELDNAME'){
console.log('Error creating new columns in Users table : subAccount')