From 7e40df38ee7c0980119c7a6130a045793ad9922d Mon Sep 17 00:00:00 2001 From: sk1982 Date: Wed, 17 Apr 2024 06:06:47 -0400 Subject: [PATCH] fix: enforce encodings on certain tables fixes #3 --- .../20240417095914-modify-table-encodings.js | 53 +++++++++++++++++++ ...0417095914-modify-table-encodings-down.sql | 1 + ...240417095914-modify-table-encodings-up.sql | 12 +++++ 3 files changed, 66 insertions(+) create mode 100644 migrations/20240417095914-modify-table-encodings.js create mode 100644 migrations/sqls/20240417095914-modify-table-encodings-down.sql create mode 100644 migrations/sqls/20240417095914-modify-table-encodings-up.sql diff --git a/migrations/20240417095914-modify-table-encodings.js b/migrations/20240417095914-modify-table-encodings.js new file mode 100644 index 0000000..dcc54f9 --- /dev/null +++ b/migrations/20240417095914-modify-table-encodings.js @@ -0,0 +1,53 @@ +'use strict'; + +var dbm; +var type; +var seed; +var fs = require('fs'); +var path = require('path'); +var Promise; + +/** + * We receive the dbmigrate dependency from dbmigrate initially. + * This enables us to not have to rely on NODE_PATH. + */ +exports.setup = function(options, seedLink) { + dbm = options.dbmigrate; + type = dbm.dataType; + seed = seedLink; + Promise = options.Promise; +}; + +exports.up = function(db) { + var filePath = path.join(__dirname, 'sqls', '20240417095914-modify-table-encodings-up.sql'); + return new Promise( function( resolve, reject ) { + fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){ + if (err) return reject(err); + console.log('received data: ' + data); + + resolve(data); + }); + }) + .then(function(data) { + return db.runSql(data); + }); +}; + +exports.down = function(db) { + var filePath = path.join(__dirname, 'sqls', '20240417095914-modify-table-encodings-down.sql'); + return new Promise( function( resolve, reject ) { + fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){ + if (err) return reject(err); + console.log('received data: ' + data); + + resolve(data); + }); + }) + .then(function(data) { + return db.runSql(data); + }); +}; + +exports._meta = { + "version": 1 +}; diff --git a/migrations/sqls/20240417095914-modify-table-encodings-down.sql b/migrations/sqls/20240417095914-modify-table-encodings-down.sql new file mode 100644 index 0000000..e0ac49d --- /dev/null +++ b/migrations/sqls/20240417095914-modify-table-encodings-down.sql @@ -0,0 +1 @@ +SELECT 1; diff --git a/migrations/sqls/20240417095914-modify-table-encodings-up.sql b/migrations/sqls/20240417095914-modify-table-encodings-up.sql new file mode 100644 index 0000000..ae71975 --- /dev/null +++ b/migrations/sqls/20240417095914-modify-table-encodings-up.sql @@ -0,0 +1,12 @@ +ALTER TABLE actaeon_chuni_static_map_icon CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; +ALTER TABLE actaeon_chuni_static_music_ext CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; +ALTER TABLE actaeon_chuni_static_music_ext CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; +ALTER TABLE actaeon_chuni_static_name_plate CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; +ALTER TABLE actaeon_chuni_static_system_voice CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; +ALTER TABLE actaeon_chuni_static_trophies CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; + +ALTER TABLE actaeon_global_config CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; + +ALTER TABLE actaeon_teams MODIFY COLUMN name VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; + +ALTER TABLE actaeon_user_ext MODIFY COLUMN dashboard VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;