mirror of https://github.com/calzoneman/sync.git
Add auto DB conversion for utf8mb4
This commit is contained in:
parent
9deff9bdb1
commit
c39c394f36
|
@ -2,7 +2,7 @@ var db = require("../database");
|
|||
var Logger = require("../logger");
|
||||
var Q = require("q");
|
||||
|
||||
const DB_VERSION = 4;
|
||||
const DB_VERSION = 5;
|
||||
var hasUpdates = [];
|
||||
|
||||
module.exports.checkVersion = function () {
|
||||
|
@ -52,6 +52,8 @@ function update(version, cb) {
|
|||
" into the CyTube process to remove the unused tables.");
|
||||
cb();
|
||||
})
|
||||
} else if (version < 5) {
|
||||
fixUtf8mb4(cb);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -220,3 +222,21 @@ module.exports.deleteOldChannelTables = function (cb) {
|
|||
}
|
||||
}).done(cb);
|
||||
};
|
||||
|
||||
function fixUtf8mb4(cb) {
|
||||
var queries = [
|
||||
"ALTER TABLE `users` MODIFY `profile` TEXT CHARACTER SET utf8mb4 NOT NULL",
|
||||
"ALTER TABLE `global_bans` MODIFY `reason` VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL",
|
||||
"ALTER TABLE `channel_libraries` MODIFY `title` VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL",
|
||||
"ALTER TABLE `channel_bans` MODIFY `reason` VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL"
|
||||
];
|
||||
|
||||
Q.allSettled(queries.map(function (query) {
|
||||
return Q.nfcall(db.query, query);
|
||||
})).then(function () {
|
||||
Logger.syslog.log("Fixed utf8mb4");
|
||||
cb();
|
||||
}).catch(function (e) {
|
||||
Logger.errlog.log("Failed to fix utf8mb4: " + e);
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue