Merge 8f4b790b54
into c3b968aa10
This commit is contained in:
commit
d83903ea82
6 changed files with 33 additions and 10 deletions
|
@ -124,7 +124,6 @@ mysql:
|
||||||
# Some installations, eg. MAMP can use a different port (8889)
|
# Some installations, eg. MAMP can use a different port (8889)
|
||||||
# MAMP users should also turn on Allow network access to MySQL otherwise MySQL might not be accessible
|
# MAMP users should also turn on Allow network access to MySQL otherwise MySQL might not be accessible
|
||||||
port: 3306
|
port: 3306
|
||||||
charset: utf8mb4
|
|
||||||
# The timezone configured on the MySQL server. This can be 'local', 'Z', or an offset in the form +HH:MM or -HH:MM
|
# The timezone configured on the MySQL server. This can be 'local', 'Z', or an offset in the form +HH:MM or -HH:MM
|
||||||
# If the MySQL server runs on the same server as Mailtrain, use 'local'
|
# If the MySQL server runs on the same server as Mailtrain, use 'local'
|
||||||
timezone: local
|
timezone: local
|
||||||
|
|
|
@ -10,6 +10,9 @@ const knex = require('knex')({
|
||||||
connection: {
|
connection: {
|
||||||
...config.mysql,
|
...config.mysql,
|
||||||
|
|
||||||
|
charset: 'utf8mb4',
|
||||||
|
multipleStatements: true,
|
||||||
|
|
||||||
// DATE and DATETIME types contain no timezone info. The MySQL driver tries to interpret them w.r.t. to local time, which
|
// DATE and DATETIME types contain no timezone info. The MySQL driver tries to interpret them w.r.t. to local time, which
|
||||||
// does not work well with assigning these values in UTC and handling them as if in UTC
|
// does not work well with assigning these values in UTC and handling them as if in UTC
|
||||||
dateStrings: [
|
dateStrings: [
|
||||||
|
|
|
@ -207,13 +207,13 @@ async function create(context, entity) {
|
||||||
|
|
||||||
await knex.schema.raw('CREATE TABLE `subscription__' + id + '` (\n' +
|
await knex.schema.raw('CREATE TABLE `subscription__' + id + '` (\n' +
|
||||||
' `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n' +
|
' `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n' +
|
||||||
' `cid` varchar(255) CHARACTER SET ascii NOT NULL,\n' +
|
' `cid` varchar(255) NOT NULL,\n' +
|
||||||
' `email` varchar(255) CHARACTER SET utf8 DEFAULT NULL,\n' +
|
' `email` varchar(255) DEFAULT NULL,\n' +
|
||||||
' `hash_email` varchar(255) CHARACTER SET ascii NOT NULL,\n' +
|
' `hash_email` varchar(255) NOT NULL,\n' +
|
||||||
' `source_email` int(11) DEFAULT NULL,\n' + // Altough this is a reference to an import, it is represented as signed int(11). This is because we use negative values for constant from SubscriptionSource
|
' `source_email` int(11) DEFAULT NULL,\n' + // Altough this is a reference to an import, it is represented as signed int(11). This is because we use negative values for constant from SubscriptionSource
|
||||||
' `opt_in_ip` varchar(100) DEFAULT NULL,\n' +
|
' `opt_in_ip` varchar(100) DEFAULT NULL,\n' +
|
||||||
' `opt_in_country` varchar(2) DEFAULT NULL,\n' +
|
' `opt_in_country` varchar(2) DEFAULT NULL,\n' +
|
||||||
' `tz` varchar(100) CHARACTER SET ascii DEFAULT NULL,\n' +
|
' `tz` varchar(100) DEFAULT NULL,\n' +
|
||||||
' `status` tinyint(4) unsigned NOT NULL DEFAULT \'1\',\n' +
|
' `status` tinyint(4) unsigned NOT NULL DEFAULT \'1\',\n' +
|
||||||
' `is_test` tinyint(4) unsigned NOT NULL DEFAULT \'0\',\n' +
|
' `is_test` tinyint(4) unsigned NOT NULL DEFAULT \'0\',\n' +
|
||||||
' `status_change` timestamp NULL DEFAULT NULL,\n' +
|
' `status_change` timestamp NULL DEFAULT NULL,\n' +
|
||||||
|
@ -233,7 +233,7 @@ async function create(context, entity) {
|
||||||
' KEY `latest_click` (`latest_click`),\n' +
|
' KEY `latest_click` (`latest_click`),\n' +
|
||||||
' KEY `created` (`created`),\n' +
|
' KEY `created` (`created`),\n' +
|
||||||
' KEY `updated` (`updated`)\n' +
|
' KEY `updated` (`updated`)\n' +
|
||||||
') ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;\n');
|
') ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci;\n');
|
||||||
|
|
||||||
await shares.rebuildPermissionsTx(tx, { entityTypeId: 'list', entityId: id });
|
await shares.rebuildPermissionsTx(tx, { entityTypeId: 'list', entityId: id });
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const config = require('./config');
|
let config = require('./config');
|
||||||
|
|
||||||
|
config.mysql.charset="utf8mb4";
|
||||||
|
config.mysql.multipleStatements=true;
|
||||||
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
client: 'mysql',
|
client: 'mysql',
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
|
||||||
|
exports.up = function(knex, Promise) {
|
||||||
|
return knex.raw('SELECT table_name FROM information_schema.tables WHERE table_schema = ?', [knex.client.database()])
|
||||||
|
.then(function(tablas) {
|
||||||
|
let sql="";
|
||||||
|
tablas=tablas[0];
|
||||||
|
for(let i=0; i<tablas.length; i++) {
|
||||||
|
sql+="ALTER TABLE "+tablas[i].table_name+" CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;";
|
||||||
|
}
|
||||||
|
//console.log(sql);
|
||||||
|
return knex.raw(sql);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = function(knex, Promise) {
|
||||||
|
|
||||||
|
};
|
|
@ -210,7 +210,7 @@ function installMailtrain {
|
||||||
mysql -u root -e "GRANT ALL PRIVILEGES ON mailtrain.* TO 'mailtrain'@'localhost';"
|
mysql -u root -e "GRANT ALL PRIVILEGES ON mailtrain.* TO 'mailtrain'@'localhost';"
|
||||||
mysql -u root -e "CREATE USER 'mailtrain_ro'@'localhost' IDENTIFIED BY '$mysqlRoPassword';"
|
mysql -u root -e "CREATE USER 'mailtrain_ro'@'localhost' IDENTIFIED BY '$mysqlRoPassword';"
|
||||||
mysql -u root -e "GRANT SELECT ON mailtrain.* TO 'mailtrain_ro'@'localhost';"
|
mysql -u root -e "GRANT SELECT ON mailtrain.* TO 'mailtrain_ro'@'localhost';"
|
||||||
mysql -u mailtrain --password="$mysqlPassword" -e "CREATE database mailtrain;"
|
mysql -u mailtrain --password="$mysqlPassword" -e "CREATE DATABASE mailtrain CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;"
|
||||||
|
|
||||||
# Add new user for the mailtrain daemon to run as
|
# Add new user for the mailtrain daemon to run as
|
||||||
useradd mailtrain || true
|
useradd mailtrain || true
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue