New project structure
Beta of extract.js for extracting english locale
This commit is contained in:
parent
e18d2b2f84
commit
2edbd67205
247 changed files with 6405 additions and 4237 deletions
|
@ -1,36 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# This installation script works on Ubuntu 14.04 and 16.04
|
||||
# Run as root!
|
||||
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
echo "This script must be run as root" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
set -e
|
||||
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# Setup MySQL user for Mailtrain
|
||||
mysql -u root --password="$ROOT_PASS" -e "CREATE USER '$DB_USER'@'localhost' IDENTIFIED BY '$DB_PASS';"
|
||||
mysql -u root --password="$ROOT_PASS" -e "GRANT ALL PRIVILEGES ON '$DB_USER'.* TO '$DB_USER'@'localhost';"
|
||||
mysql -u "$DB_USER" --password="$DB_PASS" -e "CREATE database $DB_USER;"
|
||||
|
||||
mysql -u "$DB_USER" -p"$DB_PASS" "$DB_USER" < setup/sql/mailtrain.sql
|
||||
|
||||
mysql -u mailtrain -p"$MYSQL_PASSWORD" mailtrain <<EOT
|
||||
INSERT INTO \`settings\` (\`key\`, \`value\`) VALUES ('admin_email','admin@$HOSTNAME') ON DUPLICATE KEY UPDATE \`value\`='admin@$HOSTNAME';
|
||||
INSERT INTO \`settings\` (\`key\`, \`value\`) VALUES ('default_address','admin@$HOSTNAME') ON DUPLICATE KEY UPDATE \`value\`='admin@$HOSTNAME';
|
||||
INSERT INTO \`settings\` (\`key\`, \`value\`) VALUES ('smtp_hostname','localhost') ON DUPLICATE KEY UPDATE \`value\`='localhost';
|
||||
INSERT INTO \`settings\` (\`key\`, \`value\`) VALUES ('smtp_disable_auth','') ON DUPLICATE KEY UPDATE \`value\`='';
|
||||
INSERT INTO \`settings\` (\`key\`, \`value\`) VALUES ('smtp_user','mailtrain') ON DUPLICATE KEY UPDATE \`value\`='mailtrain';
|
||||
INSERT INTO \`settings\` (\`key\`, \`value\`) VALUES ('smtp_pass','$SMTP_PASS') ON DUPLICATE KEY UPDATE \`value\`='$SMTP_PASS';
|
||||
INSERT INTO \`settings\` (\`key\`, \`value\`) VALUES ('smtp_encryption','NONE') ON DUPLICATE KEY UPDATE \`value\`='NONE';
|
||||
INSERT INTO \`settings\` (\`key\`, \`value\`) VALUES ('smtp_port','2525') ON DUPLICATE KEY UPDATE \`value\`='2525';
|
||||
INSERT INTO \`settings\` (\`key\`, \`value\`) VALUES ('default_homepage','http://$HOSTNAME/') ON DUPLICATE KEY UPDATE \`value\`='http://$HOSTNAME/';
|
||||
INSERT INTO \`settings\` (\`key\`, \`value\`) VALUES ('service_url','http://$HOSTNAME/') ON DUPLICATE KEY UPDATE \`value\`='http://$HOSTNAME/';
|
||||
INSERT INTO \`settings\` (\`key\`, \`value\`) VALUES ('dkim_api_key','$DKIM_API_KEY') ON DUPLICATE KEY UPDATE \`value\`='$DKIM_API_KEY';
|
||||
EOT
|
||||
|
||||
echo "OK"
|
|
@ -1,28 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
let faker = require('faker');
|
||||
let accounts = 100 * 1000;
|
||||
|
||||
let row = 0;
|
||||
let getNext = () => {
|
||||
|
||||
let firstName = faker.name.firstName(); // Rowan Nikolaus
|
||||
let lastName = faker.name.lastName(); // Rowan Nikolaus
|
||||
let email = faker.internet.email(firstName, lastName); // Kassandra.Haley@erich.biz
|
||||
|
||||
let subscriber = {
|
||||
firstName,
|
||||
lastName,
|
||||
email,
|
||||
company: faker.company.companyName(),
|
||||
phone: faker.phone.phoneNumber()
|
||||
};
|
||||
|
||||
process.stdout.write('\n' + Object.keys(subscriber).map(key => JSON.stringify(subscriber[key])).join(','));
|
||||
if (++row < accounts) {
|
||||
setImmediate(getNext);
|
||||
}
|
||||
};
|
||||
|
||||
process.stdout.write('First name,Last name,E-Mail,Company,Phone number');
|
||||
getNext();
|
|
@ -1,227 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# This installation script works on CentOS 7
|
||||
# Run as root!
|
||||
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
echo "This script must be run as root" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
set -e
|
||||
|
||||
yum -y install epel-release
|
||||
|
||||
curl --silent --location https://rpm.nodesource.com/setup_7.x | bash -
|
||||
yum -y install mariadb-server nodejs ImageMagick git python redis pwgen bind-utils gcc-c++ make
|
||||
|
||||
systemctl start mariadb
|
||||
systemctl enable mariadb
|
||||
|
||||
systemctl start redis
|
||||
systemctl enable redis
|
||||
|
||||
|
||||
PUBLIC_IP=`curl -s https://api.ipify.org`
|
||||
if [ ! -z "$PUBLIC_IP" ]; then
|
||||
HOSTNAME=`dig +short -x $PUBLIC_IP | sed 's/\.$//'`
|
||||
HOSTNAME="${HOSTNAME:-$PUBLIC_IP}"
|
||||
fi
|
||||
HOSTNAME="${HOSTNAME:-`hostname`}"
|
||||
|
||||
MYSQL_PASSWORD=`pwgen 12 -1`
|
||||
MYSQL_RO_PASSWORD=`pwgen 12 -1`
|
||||
DKIM_API_KEY=`pwgen 12 -1`
|
||||
SMTP_PASS=`pwgen 12 -1`
|
||||
|
||||
# Setup MySQL user for Mailtrain
|
||||
mysql -u root -e "CREATE USER 'mailtrain'@'localhost' IDENTIFIED BY '$MYSQL_PASSWORD';"
|
||||
mysql -u root -e "GRANT ALL PRIVILEGES ON mailtrain.* TO 'mailtrain'@'localhost';"
|
||||
mysql -u root -e "CREATE USER 'mailtrain_ro'@'localhost' IDENTIFIED BY '$MYSQL_RO_PASSWORD';"
|
||||
mysql -u root -e "GRANT SELECT ON mailtrain.* TO 'mailtrain_ro'@'localhost';"
|
||||
mysql -u mailtrain --password="$MYSQL_PASSWORD" -e "CREATE database mailtrain;"
|
||||
|
||||
# Enable firewall, allow connections to SSH, HTTP, HTTPS and SMTP
|
||||
for port in 80/tcp 443/tcp 25/tcp; do firewall-cmd --add-port=$port --permanent; done
|
||||
firewall-cmd --reload
|
||||
|
||||
# Fetch Mailtrain files
|
||||
mkdir -p /opt/mailtrain
|
||||
cd /opt/mailtrain
|
||||
git clone git://github.com/Mailtrain-org/mailtrain.git .
|
||||
|
||||
# Normally we would let Mailtrain itself to import the initial SQL data but in this case
|
||||
# we need to modify it, before we start Mailtrain
|
||||
mysql -u mailtrain -p"$MYSQL_PASSWORD" mailtrain < setup/sql/mailtrain.sql
|
||||
|
||||
mysql -u mailtrain -p"$MYSQL_PASSWORD" mailtrain <<EOT
|
||||
INSERT INTO \`settings\` (\`key\`, \`value\`) VALUES ('admin_email','admin@$HOSTNAME') ON DUPLICATE KEY UPDATE \`value\`='admin@$HOSTNAME';
|
||||
INSERT INTO \`settings\` (\`key\`, \`value\`) VALUES ('default_address','admin@$HOSTNAME') ON DUPLICATE KEY UPDATE \`value\`='admin@$HOSTNAME';
|
||||
INSERT INTO \`settings\` (\`key\`, \`value\`) VALUES ('smtp_hostname','localhost') ON DUPLICATE KEY UPDATE \`value\`='localhost';
|
||||
INSERT INTO \`settings\` (\`key\`, \`value\`) VALUES ('smtp_disable_auth','') ON DUPLICATE KEY UPDATE \`value\`='';
|
||||
INSERT INTO \`settings\` (\`key\`, \`value\`) VALUES ('smtp_user','mailtrain') ON DUPLICATE KEY UPDATE \`value\`='mailtrain';
|
||||
INSERT INTO \`settings\` (\`key\`, \`value\`) VALUES ('smtp_pass','$SMTP_PASS') ON DUPLICATE KEY UPDATE \`value\`='$SMTP_PASS';
|
||||
INSERT INTO \`settings\` (\`key\`, \`value\`) VALUES ('smtp_encryption','NONE') ON DUPLICATE KEY UPDATE \`value\`='NONE';
|
||||
INSERT INTO \`settings\` (\`key\`, \`value\`) VALUES ('smtp_port','2525') ON DUPLICATE KEY UPDATE \`value\`='2525';
|
||||
INSERT INTO \`settings\` (\`key\`, \`value\`) VALUES ('default_homepage','http://$HOSTNAME/') ON DUPLICATE KEY UPDATE \`value\`='http://$HOSTNAME/';
|
||||
INSERT INTO \`settings\` (\`key\`, \`value\`) VALUES ('service_url','http://$HOSTNAME/') ON DUPLICATE KEY UPDATE \`value\`='http://$HOSTNAME/';
|
||||
INSERT INTO \`settings\` (\`key\`, \`value\`) VALUES ('dkim_api_key','$DKIM_API_KEY') ON DUPLICATE KEY UPDATE \`value\`='$DKIM_API_KEY';
|
||||
EOT
|
||||
|
||||
# Add new user for the mailtrain daemon to run as
|
||||
useradd mailtrain || true
|
||||
useradd zone-mta || true
|
||||
|
||||
# Setup installation configuration
|
||||
cat >> config/production.toml <<EOT
|
||||
user="mailtrain"
|
||||
group="mailtrain"
|
||||
roUser="nobody"
|
||||
roGroup="nobody"
|
||||
[log]
|
||||
level="error"
|
||||
[www]
|
||||
port=80
|
||||
secret="`pwgen -1`"
|
||||
[mysql]
|
||||
password="$MYSQL_PASSWORD"
|
||||
[redis]
|
||||
enabled=true
|
||||
[queue]
|
||||
processes=5
|
||||
[reports]
|
||||
enabled=true
|
||||
EOT
|
||||
|
||||
cat >> workers/reports/config/production.toml <<EOT
|
||||
[log]
|
||||
level="error"
|
||||
[mysql]
|
||||
user="mailtrain_ro"
|
||||
password="$MYSQL_RO_PASSWORD"
|
||||
EOT
|
||||
|
||||
# Install required node packages
|
||||
npm install --no-progress --production
|
||||
chown -R mailtrain:mailtrain .
|
||||
chmod o-rwx config
|
||||
|
||||
# Setup log rotation to not spend up entire storage on logs
|
||||
cat <<EOM > /etc/logrotate.d/mailtrain
|
||||
/var/log/mailtrain.log {
|
||||
daily
|
||||
rotate 12
|
||||
compress
|
||||
delaycompress
|
||||
missingok
|
||||
notifempty
|
||||
copytruncate
|
||||
nomail
|
||||
}
|
||||
EOM
|
||||
|
||||
# Set up systemd service script
|
||||
cp setup/mailtrain-centos7.service /etc/systemd/system/mailtrain.service
|
||||
systemctl enable mailtrain.service
|
||||
|
||||
# Fetch ZoneMTA files
|
||||
mkdir -p /opt/zone-mta
|
||||
cd /opt/zone-mta
|
||||
git clone git://github.com/zone-eu/zone-mta.git .
|
||||
git checkout 6964091273
|
||||
|
||||
# Ensure queue folder
|
||||
mkdir -p /var/data/zone-mta/mailtrain
|
||||
|
||||
# Setup installation configuration
|
||||
cat >> config/production.json <<EOT
|
||||
{
|
||||
"name": "Mailtrain",
|
||||
"user": "zone-mta",
|
||||
"group": "zone-mta",
|
||||
"queue": {
|
||||
"db": "/var/data/zone-mta/mailtrain"
|
||||
},
|
||||
"smtpInterfaces": {
|
||||
"feeder": {
|
||||
"enabled": true,
|
||||
"port": 2525,
|
||||
"processes": 2,
|
||||
"authentication": true
|
||||
}
|
||||
},
|
||||
"api": {
|
||||
"maildrop": false,
|
||||
"user": "mailtrain",
|
||||
"pass": "$SMTP_PASS"
|
||||
},
|
||||
"log": {
|
||||
"level": "info",
|
||||
"syslog": true
|
||||
},
|
||||
"plugins": {
|
||||
"core/email-bounce": false,
|
||||
"core/http-bounce": {
|
||||
"enabled": "main",
|
||||
"url": "http://localhost/webhooks/zone-mta"
|
||||
},
|
||||
"core/http-auth": {
|
||||
"enabled": ["receiver", "main"],
|
||||
"url": "http://localhost:8080/test-auth"
|
||||
},
|
||||
"core/default-headers": {
|
||||
"enabled": ["receiver", "main", "sender"],
|
||||
"futureDate": false,
|
||||
"xOriginatingIP": false
|
||||
},
|
||||
"core/http-config": {
|
||||
"enabled": ["main", "receiver"],
|
||||
"url": "http://localhost/webhooks/zone-mta/sender-config?api_token=$DKIM_API_KEY"
|
||||
},
|
||||
"core/rcpt-mx": false
|
||||
},
|
||||
"pools": {
|
||||
"default": [{
|
||||
"address": "0.0.0.0",
|
||||
"name": "$HOSTNAME"
|
||||
}]
|
||||
},
|
||||
"zones": {
|
||||
"default": {
|
||||
"processes": 3,
|
||||
"connections": 5,
|
||||
"throttling": false,
|
||||
"pool": "default"
|
||||
},
|
||||
"transactional": {
|
||||
"processes": 1,
|
||||
"connections": 1,
|
||||
"pool": "default"
|
||||
}
|
||||
},
|
||||
"domainConfig": {
|
||||
"default": {
|
||||
"maxConnections": 4
|
||||
}
|
||||
}
|
||||
}
|
||||
EOT
|
||||
|
||||
# Install required node packages
|
||||
npm install --no-progress --production
|
||||
npm install leveldown
|
||||
|
||||
# Ensure queue folder is owned by MTA user
|
||||
chown -R zone-mta:zone-mta /var/data/zone-mta/mailtrain
|
||||
|
||||
# Set up systemd service script
|
||||
cp setup/zone-mta.service /etc/systemd/system/
|
||||
systemctl enable zone-mta.service
|
||||
|
||||
# Start the service
|
||||
systemctl daemon-reload
|
||||
|
||||
systemctl start zone-mta.service
|
||||
systemctl start mailtrain.service
|
||||
|
||||
echo "Success! Open http://$HOSTNAME/ and log in as admin:test";
|
240
setup/install.sh
240
setup/install.sh
|
@ -1,240 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# This installation script works on Ubuntu 14.04 and 16.04
|
||||
# Run as root!
|
||||
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
echo "This script must be run as root" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
set -e
|
||||
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
MYSQL_ROOT_PASSWORD=`pwgen 12 -1`
|
||||
|
||||
debconf-set-selections <<< 'mariadb-server-5.5 mysql-server/root_password password $MYSQL_ROOT_PASSWORD'
|
||||
debconf-set-selections <<< 'mariadb-server-5.5 mysql-server/root_password_again password $MYSQL_ROOT_PASSWORD'
|
||||
|
||||
curl -sL https://deb.nodesource.com/setup_7.x | bash -
|
||||
apt-get -q -y install mariadb-server pwgen nodejs imagemagick git ufw build-essential dnsutils python software-properties-common
|
||||
|
||||
apt-add-repository -y ppa:chris-lea/redis-server
|
||||
apt-get update
|
||||
apt-get -q -y install redis-server
|
||||
|
||||
apt-get clean
|
||||
|
||||
PUBLIC_IP=`curl -s https://api.ipify.org`
|
||||
if [ ! -z "$PUBLIC_IP" ]; then
|
||||
HOSTNAME=`dig +short -x $PUBLIC_IP | sed 's/\.$//'`
|
||||
HOSTNAME="${HOSTNAME:-$PUBLIC_IP}"
|
||||
fi
|
||||
HOSTNAME="${HOSTNAME:-`hostname`}"
|
||||
|
||||
MYSQL_PASSWORD=`pwgen 12 -1`
|
||||
MYSQL_RO_PASSWORD=`pwgen 12 -1`
|
||||
DKIM_API_KEY=`pwgen 12 -1`
|
||||
SMTP_PASS=`pwgen 12 -1`
|
||||
|
||||
# Setup MySQL user for Mailtrain
|
||||
mysql -u root -e "CREATE USER 'mailtrain'@'localhost' IDENTIFIED BY '$MYSQL_PASSWORD';" -p$MYSQL_ROOT_PASSWORD
|
||||
mysql -u root -e "GRANT ALL PRIVILEGES ON mailtrain.* TO 'mailtrain'@'localhost';" -p$MYSQL_ROOT_PASSWORD
|
||||
mysql -u root -e "CREATE USER 'mailtrain_ro'@'localhost' IDENTIFIED BY '$MYSQL_RO_PASSWORD';" -p$MYSQL_ROOT_PASSWORD
|
||||
mysql -u root -e "GRANT SELECT ON mailtrain.* TO 'mailtrain_ro'@'localhost';" -p$MYSQL_ROOT_PASSWORD
|
||||
mysql -u mailtrain --password="$MYSQL_PASSWORD" -e "CREATE database mailtrain;"
|
||||
|
||||
# Enable firewall, allow connections to SSH, HTTP, HTTPS and SMTP
|
||||
ufw allow 22/tcp
|
||||
ufw allow 80/tcp
|
||||
ufw allow 443/tcp
|
||||
ufw allow 25/tcp
|
||||
ufw --force enable
|
||||
|
||||
# Fetch Mailtrain files
|
||||
mkdir -p /opt/mailtrain
|
||||
cd /opt/mailtrain
|
||||
git clone git://github.com/Mailtrain-org/mailtrain.git .
|
||||
|
||||
# Normally we would let Mailtrain itself to import the initial SQL data but in this case
|
||||
# we need to modify it, before we start Mailtrain
|
||||
mysql -u mailtrain -p"$MYSQL_PASSWORD" mailtrain < setup/sql/mailtrain.sql
|
||||
|
||||
mysql -u mailtrain -p"$MYSQL_PASSWORD" mailtrain <<EOT
|
||||
INSERT INTO \`settings\` (\`key\`, \`value\`) VALUES ('admin_email','admin@$HOSTNAME') ON DUPLICATE KEY UPDATE \`value\`='admin@$HOSTNAME';
|
||||
INSERT INTO \`settings\` (\`key\`, \`value\`) VALUES ('default_address','admin@$HOSTNAME') ON DUPLICATE KEY UPDATE \`value\`='admin@$HOSTNAME';
|
||||
INSERT INTO \`settings\` (\`key\`, \`value\`) VALUES ('smtp_hostname','localhost') ON DUPLICATE KEY UPDATE \`value\`='localhost';
|
||||
INSERT INTO \`settings\` (\`key\`, \`value\`) VALUES ('smtp_disable_auth','') ON DUPLICATE KEY UPDATE \`value\`='';
|
||||
INSERT INTO \`settings\` (\`key\`, \`value\`) VALUES ('smtp_user','mailtrain') ON DUPLICATE KEY UPDATE \`value\`='mailtrain';
|
||||
INSERT INTO \`settings\` (\`key\`, \`value\`) VALUES ('smtp_pass','$SMTP_PASS') ON DUPLICATE KEY UPDATE \`value\`='$SMTP_PASS';
|
||||
INSERT INTO \`settings\` (\`key\`, \`value\`) VALUES ('smtp_encryption','NONE') ON DUPLICATE KEY UPDATE \`value\`='NONE';
|
||||
INSERT INTO \`settings\` (\`key\`, \`value\`) VALUES ('smtp_port','2525') ON DUPLICATE KEY UPDATE \`value\`='2525';
|
||||
INSERT INTO \`settings\` (\`key\`, \`value\`) VALUES ('default_homepage','http://$HOSTNAME/') ON DUPLICATE KEY UPDATE \`value\`='http://$HOSTNAME/';
|
||||
INSERT INTO \`settings\` (\`key\`, \`value\`) VALUES ('service_url','http://$HOSTNAME/') ON DUPLICATE KEY UPDATE \`value\`='http://$HOSTNAME/';
|
||||
INSERT INTO \`settings\` (\`key\`, \`value\`) VALUES ('dkim_api_key','$DKIM_API_KEY') ON DUPLICATE KEY UPDATE \`value\`='$DKIM_API_KEY';
|
||||
EOT
|
||||
|
||||
# Add new user for the mailtrain daemon to run as
|
||||
useradd mailtrain || true
|
||||
useradd zone-mta || true
|
||||
|
||||
# Setup installation configuration
|
||||
cat >> config/production.toml <<EOT
|
||||
user="mailtrain"
|
||||
group="mailtrain"
|
||||
[log]
|
||||
level="error"
|
||||
[www]
|
||||
port=80
|
||||
secret="`pwgen -1`"
|
||||
[mysql]
|
||||
password="$MYSQL_PASSWORD"
|
||||
[redis]
|
||||
enabled=true
|
||||
[queue]
|
||||
processes=5
|
||||
EOT
|
||||
|
||||
cat >> workers/reports/config/production.toml <<EOT
|
||||
[log]
|
||||
level="error"
|
||||
[mysql]
|
||||
user="mailtrain_ro"
|
||||
password="$MYSQL_RO_PASSWORD"
|
||||
EOT
|
||||
|
||||
# Install required node packages
|
||||
npm install --no-progress --production
|
||||
chown -R mailtrain:mailtrain .
|
||||
chmod o-rwx config
|
||||
|
||||
# Setup log rotation to not spend up entire storage on logs
|
||||
cat <<EOM > /etc/logrotate.d/mailtrain
|
||||
/var/log/mailtrain.log {
|
||||
daily
|
||||
rotate 12
|
||||
compress
|
||||
delaycompress
|
||||
missingok
|
||||
notifempty
|
||||
copytruncate
|
||||
nomail
|
||||
}
|
||||
EOM
|
||||
|
||||
if [ -d "/run/systemd/system" ]; then
|
||||
# Set up systemd service script
|
||||
cp setup/mailtrain.service /etc/systemd/system/
|
||||
systemctl enable mailtrain.service
|
||||
else
|
||||
# Set up upstart service script
|
||||
cp setup/mailtrain.conf /etc/init/
|
||||
fi
|
||||
|
||||
# Fetch ZoneMTA files
|
||||
mkdir -p /opt/zone-mta
|
||||
cd /opt/zone-mta
|
||||
git clone git://github.com/zone-eu/zone-mta.git .
|
||||
git checkout 6964091273
|
||||
|
||||
# Ensure queue folder
|
||||
mkdir -p /var/data/zone-mta/mailtrain
|
||||
|
||||
# Setup installation configuration
|
||||
cat >> config/production.json <<EOT
|
||||
{
|
||||
"name": "Mailtrain",
|
||||
"user": "zone-mta",
|
||||
"group": "zone-mta",
|
||||
"queue": {
|
||||
"db": "/var/data/zone-mta/mailtrain"
|
||||
},
|
||||
"smtpInterfaces": {
|
||||
"feeder": {
|
||||
"enabled": true,
|
||||
"port": 2525,
|
||||
"processes": 2,
|
||||
"authentication": true
|
||||
}
|
||||
},
|
||||
"api": {
|
||||
"maildrop": false,
|
||||
"user": "mailtrain",
|
||||
"pass": "$SMTP_PASS"
|
||||
},
|
||||
"log": {
|
||||
"level": "info",
|
||||
"syslog": true
|
||||
},
|
||||
"plugins": {
|
||||
"core/email-bounce": false,
|
||||
"core/http-bounce": {
|
||||
"enabled": "main",
|
||||
"url": "http://localhost/webhooks/zone-mta"
|
||||
},
|
||||
"core/http-auth": {
|
||||
"enabled": ["receiver", "main"],
|
||||
"url": "http://localhost:8080/test-auth"
|
||||
},
|
||||
"core/default-headers": {
|
||||
"enabled": ["receiver", "main", "sender"],
|
||||
"futureDate": false,
|
||||
"xOriginatingIP": false
|
||||
},
|
||||
"core/http-config": {
|
||||
"enabled": ["main", "receiver"],
|
||||
"url": "http://localhost/webhooks/zone-mta/sender-config?api_token=$DKIM_API_KEY"
|
||||
},
|
||||
"core/rcpt-mx": false
|
||||
},
|
||||
"pools": {
|
||||
"default": [{
|
||||
"address": "0.0.0.0",
|
||||
"name": "$HOSTNAME"
|
||||
}]
|
||||
},
|
||||
"zones": {
|
||||
"default": {
|
||||
"processes": 3,
|
||||
"connections": 5,
|
||||
"throttling": false,
|
||||
"pool": "default"
|
||||
},
|
||||
"transactional": {
|
||||
"processes": 1,
|
||||
"connections": 1,
|
||||
"pool": "default"
|
||||
}
|
||||
},
|
||||
"domainConfig": {
|
||||
"default": {
|
||||
"maxConnections": 4
|
||||
}
|
||||
}
|
||||
}
|
||||
EOT
|
||||
|
||||
# Install required node packages
|
||||
npm install --no-progress --production
|
||||
npm install leveldown
|
||||
|
||||
# Ensure queue folder is owned by MTA user
|
||||
chown -R zone-mta:zone-mta /var/data/zone-mta/mailtrain
|
||||
|
||||
if [ -d "/run/systemd/system" ]; then
|
||||
# Set up systemd service script
|
||||
cp setup/zone-mta.service /etc/systemd/system/
|
||||
systemctl enable zone-mta.service
|
||||
else
|
||||
# Set up upstart service script
|
||||
cp setup/zone-mta.conf /etc/init/
|
||||
fi
|
||||
|
||||
# Start the service
|
||||
service zone-mta start
|
||||
service mailtrain start
|
||||
|
||||
echo $MYSQL_ROOT_PASSWORD > ~/mysql_root_password
|
||||
echo "MySQL root password: $MYSQL_ROOT_PASSWORD"
|
||||
echo "Success! Open http://$HOSTNAME/ and log in as admin:test";
|
|
@ -1,9 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
if (!process.env.NODE_CONFIG_DIR) {
|
||||
process.env.NODE_CONFIG_DIR = __dirname + '/../../config';
|
||||
}
|
||||
|
||||
const config = require('config');
|
||||
|
||||
module.exports = config;
|
|
@ -1,8 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
const config = require('./config');
|
||||
|
||||
module.exports = {
|
||||
client: 'mysql2',
|
||||
connection: config.mysql
|
||||
};
|
File diff suppressed because it is too large
Load diff
|
@ -1,12 +0,0 @@
|
|||
# This example sets up mailtrain.org/www.mailtrain.org virtual domains
|
||||
# for Apache2 and proxies requests for these domains to localhost port 3000
|
||||
|
||||
# Using mod_proxy is not enabled by default, so you probably need to do this yourself
|
||||
|
||||
<VirtualHost *:80>
|
||||
ProxyPreserveHost On
|
||||
ProxyPass "/" "http://127.0.0.1:3000/"
|
||||
ProxyPassReverse "/" "http://127.0.0.1:3000/"
|
||||
ServerName mailtrain.org
|
||||
ServerAlias www.mailtrain.org
|
||||
</VirtualHost>
|
|
@ -1,16 +0,0 @@
|
|||
[Unit]
|
||||
Description=Mailtrain server
|
||||
Requires=mariadb.service
|
||||
After=syslog.target network.target
|
||||
|
||||
[Service]
|
||||
Environment="NODE_ENV=production"
|
||||
WorkingDirectory=/opt/mailtrain
|
||||
ExecStart=/usr/bin/node index.js
|
||||
Type=simple
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
# Alias=mailtrain.service
|
|
@ -1,20 +0,0 @@
|
|||
# This example sets up mailtrain.org/www.mailtrain.org virtual domains
|
||||
# for Nginx and proxies requests for these domains to localhost port 3000
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
|
||||
server_name mailtrain.org www.mailtrain.org;
|
||||
access_log /var/log/nginx/mailtrain.log;
|
||||
|
||||
location / {
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header HOST $http_host;
|
||||
proxy_set_header X-NginX-Proxy true;
|
||||
|
||||
proxy_pass http://127.0.0.1:3000;
|
||||
proxy_redirect off;
|
||||
}
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
# upstart script for example server
|
||||
|
||||
description "Mailtrain server"
|
||||
author "Andris Reinman <andris@kreata.ee>"
|
||||
|
||||
start on runlevel [2345]
|
||||
stop on runlevel [!2345]
|
||||
|
||||
env NODE_ENV=production
|
||||
|
||||
respawn
|
||||
respawn limit 10 0
|
||||
|
||||
script
|
||||
cd /opt/mailtrain
|
||||
exec node index.js >> /var/log/mailtrain.log 2>&1
|
||||
end script
|
|
@ -1,16 +0,0 @@
|
|||
[Unit]
|
||||
Description=Mailtrain server
|
||||
Requires=mysql.service
|
||||
After=syslog.target network.target
|
||||
|
||||
[Service]
|
||||
Environment="NODE_ENV=production"
|
||||
WorkingDirectory=/opt/mailtrain
|
||||
ExecStart=/usr/bin/node index.js
|
||||
Type=simple
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
# Alias=mailtrain.service
|
|
@ -1,218 +0,0 @@
|
|||
SET UNIQUE_CHECKS=0;
|
||||
SET FOREIGN_KEY_CHECKS=0;
|
||||
|
||||
CREATE TABLE `campaign` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`list` int(11) unsigned NOT NULL,
|
||||
`segment` int(11) unsigned NOT NULL,
|
||||
`subscription` int(11) unsigned NOT NULL,
|
||||
`status` tinyint(4) unsigned NOT NULL DEFAULT '0',
|
||||
`response` varchar(255) DEFAULT NULL,
|
||||
`response_id` varchar(255) CHARACTER SET ascii DEFAULT NULL,
|
||||
`updated` timestamp NULL DEFAULT NULL,
|
||||
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `list` (`list`,`segment`,`subscription`),
|
||||
KEY `created` (`created`),
|
||||
KEY `response_id` (`response_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
CREATE TABLE `campaign_tracker` (
|
||||
`list` int(11) unsigned NOT NULL,
|
||||
`subscriber` int(11) unsigned NOT NULL,
|
||||
`link` int(11) NOT NULL,
|
||||
`ip` varchar(100) CHARACTER SET ascii DEFAULT NULL,
|
||||
`country` varchar(2) CHARACTER SET ascii DEFAULT NULL,
|
||||
`count` int(11) unsigned NOT NULL DEFAULT '1',
|
||||
PRIMARY KEY (`list`,`subscriber`,`link`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
CREATE TABLE `campaigns` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`cid` varchar(255) CHARACTER SET ascii NOT NULL,
|
||||
`name` varchar(255) NOT NULL DEFAULT '',
|
||||
`description` text,
|
||||
`list` int(11) unsigned NOT NULL,
|
||||
`segment` int(11) unsigned DEFAULT NULL,
|
||||
`template` int(11) unsigned NOT NULL,
|
||||
`from` varchar(255) DEFAULT '',
|
||||
`address` varchar(255) DEFAULT '',
|
||||
`subject` varchar(255) DEFAULT '',
|
||||
`html` text,
|
||||
`text` text,
|
||||
`status` tinyint(4) unsigned NOT NULL DEFAULT '1',
|
||||
`status_change` timestamp NULL DEFAULT NULL,
|
||||
`delivered` int(11) unsigned NOT NULL DEFAULT '0',
|
||||
`opened` int(11) unsigned NOT NULL DEFAULT '0',
|
||||
`clicks` int(11) unsigned NOT NULL DEFAULT '0',
|
||||
`unsubscribed` int(11) unsigned NOT NULL DEFAULT '0',
|
||||
`bounced` int(1) unsigned NOT NULL DEFAULT '0',
|
||||
`complained` int(1) unsigned NOT NULL DEFAULT '0',
|
||||
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `cid` (`cid`),
|
||||
KEY `name` (`name`(191)),
|
||||
KEY `status` (`status`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
CREATE TABLE `confirmations` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`cid` varchar(255) CHARACTER SET ascii NOT NULL,
|
||||
`list` int(11) unsigned NOT NULL,
|
||||
`email` varchar(255) NOT NULL,
|
||||
`data` text NOT NULL,
|
||||
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `cid` (`cid`),
|
||||
KEY `list` (`list`),
|
||||
CONSTRAINT `confirmations_ibfk_1` FOREIGN KEY (`list`) REFERENCES `lists` (`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
CREATE TABLE `custom_fields` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`list` int(11) unsigned NOT NULL,
|
||||
`name` varchar(255) CHARACTER SET utf8mb4 DEFAULT '',
|
||||
`key` varchar(100) CHARACTER SET ascii NOT NULL,
|
||||
`default_value` varchar(255) CHARACTER SET utf8mb4 DEFAULT NULL,
|
||||
`type` varchar(255) CHARACTER SET ascii NOT NULL DEFAULT '',
|
||||
`group` int(11) unsigned DEFAULT NULL,
|
||||
`column` varchar(255) CHARACTER SET ascii DEFAULT NULL,
|
||||
`visible` tinyint(4) unsigned NOT NULL DEFAULT '1',
|
||||
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `list` (`list`,`column`),
|
||||
KEY `list_2` (`list`),
|
||||
CONSTRAINT `custom_fields_ibfk_1` FOREIGN KEY (`list`) REFERENCES `lists` (`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
CREATE TABLE `importer` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`list` int(11) unsigned NOT NULL,
|
||||
`type` tinyint(4) unsigned NOT NULL DEFAULT '1',
|
||||
`path` varchar(255) NOT NULL DEFAULT '',
|
||||
`size` int(11) unsigned NOT NULL DEFAULT '0',
|
||||
`delimiter` varchar(1) CHARACTER SET ascii NOT NULL DEFAULT ',',
|
||||
`status` tinyint(4) unsigned NOT NULL DEFAULT '0',
|
||||
`error` varchar(255) DEFAULT NULL,
|
||||
`processed` int(11) unsigned NOT NULL DEFAULT '0',
|
||||
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`mapping` text CHARACTER SET utf8mb4 NOT NULL,
|
||||
`finished` timestamp NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `list` (`list`),
|
||||
CONSTRAINT `importer_ibfk_1` FOREIGN KEY (`list`) REFERENCES `lists` (`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
CREATE TABLE `links` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`cid` varchar(255) CHARACTER SET ascii NOT NULL DEFAULT '',
|
||||
`campaign` int(11) unsigned NOT NULL,
|
||||
`url` varchar(255) CHARACTER SET ascii NOT NULL DEFAULT '',
|
||||
`clicks` int(11) unsigned NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `cid` (`cid`),
|
||||
UNIQUE KEY `campaign_2` (`campaign`,`url`),
|
||||
KEY `campaign` (`campaign`),
|
||||
CONSTRAINT `links_ibfk_1` FOREIGN KEY (`campaign`) REFERENCES `campaigns` (`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
CREATE TABLE `lists` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`cid` varchar(255) CHARACTER SET ascii NOT NULL,
|
||||
`name` varchar(255) NOT NULL DEFAULT '',
|
||||
`description` text,
|
||||
`subscribers` int(11) unsigned DEFAULT '0',
|
||||
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `cid` (`cid`),
|
||||
KEY `name` (`name`(191))
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
CREATE TABLE `segment_rules` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`segment` int(11) unsigned NOT NULL,
|
||||
`column` varchar(255) CHARACTER SET ascii NOT NULL DEFAULT '',
|
||||
`value` varchar(255) NOT NULL DEFAULT '',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `segment` (`segment`),
|
||||
CONSTRAINT `segment_rules_ibfk_1` FOREIGN KEY (`segment`) REFERENCES `segments` (`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
CREATE TABLE `segments` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`list` int(11) unsigned NOT NULL,
|
||||
`name` varchar(255) NOT NULL DEFAULT '',
|
||||
`type` tinyint(4) unsigned NOT NULL,
|
||||
`created` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `list` (`list`),
|
||||
KEY `name` (`name`),
|
||||
CONSTRAINT `segments_ibfk_1` FOREIGN KEY (`list`) REFERENCES `lists` (`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
CREATE TABLE `settings` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`key` varchar(255) CHARACTER SET ascii NOT NULL DEFAULT '',
|
||||
`value` text NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `key` (`key`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
LOCK TABLES `settings` WRITE;
|
||||
INSERT INTO `settings` VALUES (1,'smtp_hostname','localhost'),(2,'smtp_port','465'),(3,'smtp_encryption','TLS'),(4,'smtp_user','username'),(5,'smtp_pass','password'),(6,'service_url','http://localhost:3000/'),(7,'admin_email','admin@example.com'),(8,'smtp_max_connections','5'),(9,'smtp_max_messages','100'),(10,'smtp_log',''),(11,'default_sender','My Awesome Company'),(12,'default_postaddress','1234 Main Street'),(13,'default_from','My Awesome Company'),(14,'default_address','admin@example.com'),(15,'default_subject','Test message'),(16,'default_homepage','http://localhost:3000/');
|
||||
UNLOCK TABLES;
|
||||
|
||||
CREATE TABLE `subscription` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`cid` varchar(255) CHARACTER SET ascii NOT NULL,
|
||||
`email` varchar(255) CHARACTER SET utf8 NOT NULL DEFAULT '',
|
||||
`opt_in_ip` varchar(100) DEFAULT NULL,
|
||||
`opt_in_country` varchar(2) DEFAULT NULL,
|
||||
`imported` int(11) unsigned DEFAULT NULL,
|
||||
`status` tinyint(4) unsigned NOT NULL DEFAULT '1',
|
||||
`status_change` timestamp NULL DEFAULT NULL,
|
||||
`latest_open` timestamp NULL DEFAULT NULL,
|
||||
`latest_click` timestamp NULL DEFAULT NULL,
|
||||
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`first_name` varchar(255) DEFAULT NULL,
|
||||
`last_name` varchar(255) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `email` (`email`),
|
||||
UNIQUE KEY `cid` (`cid`),
|
||||
KEY `status` (`status`),
|
||||
KEY `first_name` (`first_name`(191)),
|
||||
KEY `last_name` (`last_name`(191))
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
CREATE TABLE `templates` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(255) NOT NULL DEFAULT '',
|
||||
`description` text,
|
||||
`html` text,
|
||||
`text` text,
|
||||
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `name` (`name`(191))
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
CREATE TABLE `users` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`username` varchar(255) NOT NULL DEFAULT '',
|
||||
`password` varchar(255) NOT NULL DEFAULT '',
|
||||
`email` varchar(255) CHARACTER SET utf8 DEFAULT NULL,
|
||||
`reset_token` varchar(255) CHARACTER SET ascii DEFAULT NULL,
|
||||
`reset_expire` timestamp NULL DEFAULT NULL,
|
||||
`created` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `email` (`email`),
|
||||
KEY `username` (`username`(191)),
|
||||
KEY `reset` (`reset_token`),
|
||||
KEY `check_reset` (`username`(191),`reset_token`,`reset_expire`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
LOCK TABLES `users` WRITE;
|
||||
INSERT INTO `users` VALUES (1,'admin','$2a$10$mzKU71G62evnGB2PvQA4k..Wf9jASk.c7a8zRMHh6qQVjYJ2r/g/K','admin@example.com',NULL,NULL,NOW());
|
||||
UNLOCK TABLES;
|
||||
|
||||
SET UNIQUE_CHECKS=1;
|
||||
SET FOREIGN_KEY_CHECKS=1;
|
|
@ -1,50 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
let config = require('config');
|
||||
let spawn = require('child_process').spawn;
|
||||
let log = require('npmlog');
|
||||
let path = require('path');
|
||||
let fs = require('fs');
|
||||
|
||||
log.level = 'verbose';
|
||||
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
log.error('sqldrop', 'This script does not run in production');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV === 'test' && !fs.existsSync(path.join(__dirname, '..', '..', 'config', 'test.toml'))) {
|
||||
log.error('sqldrop', 'This script only runs in test if config/test.toml (i.e. a dedicated test database) is present');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
function createDump(callback) {
|
||||
let cmd = spawn(path.join(__dirname, 'drop.sh'), [], {
|
||||
env: {
|
||||
MYSQL_HOST: config.mysql.host || 'localhost',
|
||||
MYSQL_DB: config.mysql.database,
|
||||
MYSQL_PORT: config.mysql.port || 3306,
|
||||
MYSQL_USER: config.mysql.user,
|
||||
MYSQL_PASSWORD: config.mysql.password
|
||||
}
|
||||
});
|
||||
|
||||
cmd.stdout.pipe(process.stdout);
|
||||
cmd.stderr.pipe(process.stderr);
|
||||
|
||||
cmd.on('close', code => {
|
||||
if (code) {
|
||||
return callback(new Error('drop command exited with code ' + code));
|
||||
}
|
||||
return callback(null, true);
|
||||
});
|
||||
}
|
||||
|
||||
createDump(err => {
|
||||
if (err) {
|
||||
log.error('sqldrop', err);
|
||||
process.exit(1);
|
||||
}
|
||||
log.info('sqldrop', 'Command completed, all tables dropped from "%s"', config.mysql.database);
|
||||
process.exit(0);
|
||||
});
|
|
@ -1,3 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
mysqldump -h "$MYSQL_HOST" -P "$MYSQL_PORT" -u "$MYSQL_USER" "-p${MYSQL_PASSWORD}" --add-drop-table --no-data "$MYSQL_DB" | grep -e '^DROP \| FOREIGN_KEY_CHECKS' | mysql -h "$MYSQL_HOST" -P "$MYSQL_PORT" -u "$MYSQL_USER" "-p${MYSQL_PASSWORD}" "$MYSQL_DB"
|
|
@ -1,40 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
console.log('This script does not run in production'); // eslint-disable-line no-console
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
let config = require('config');
|
||||
let spawn = require('child_process').spawn;
|
||||
let log = require('npmlog');
|
||||
|
||||
log.level = 'verbose';
|
||||
|
||||
function createDump(callback) {
|
||||
let cmd = spawn('mysqldump', ['-h', config.mysql.host || 'localhost', '-P', config.mysql.port || 3306, '-u', config.mysql.user, '-p' + config.mysql.password, '--skip-opt', '--quick', '--compact', '--complete-insert', '--create-options', '--tz-utc', '--no-set-names', '--skip-set-charset', '--skip-comments', config.mysql.database]);
|
||||
|
||||
process.stdout.write('SET UNIQUE_CHECKS=0;\nSET FOREIGN_KEY_CHECKS=0;\n\n');
|
||||
|
||||
cmd.stdout.pipe(process.stdout);
|
||||
cmd.stderr.pipe(process.stderr);
|
||||
|
||||
cmd.on('close', code => {
|
||||
if (code) {
|
||||
return callback(new Error('mysqldump command exited with code ' + code));
|
||||
}
|
||||
|
||||
process.stdout.write('\nSET UNIQUE_CHECKS=1;\nSET FOREIGN_KEY_CHECKS=1;\n');
|
||||
|
||||
return callback(null, true);
|
||||
});
|
||||
}
|
||||
|
||||
createDump(err => {
|
||||
if (err) {
|
||||
log.error('sqldump', err);
|
||||
process.exit(1);
|
||||
}
|
||||
log.info('sqldump', 'MySQL Dump Completed');
|
||||
process.exit(0);
|
||||
});
|
|
@ -1,26 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
let dbcheck = require('../../lib/dbcheck');
|
||||
let log = require('npmlog');
|
||||
let path = require('path');
|
||||
let fs = require('fs');
|
||||
|
||||
log.level = 'verbose';
|
||||
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
log.error('sqlinit', 'This script does not run in production');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV === 'test' && !fs.existsSync(path.join(__dirname, '..', '..', 'config', 'test.toml'))) {
|
||||
log.error('sqlinit', 'This script only runs in test if config/test.toml (i.e. a dedicated test database) is present');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
dbcheck(err => {
|
||||
if (err) {
|
||||
log.error('DB', err);
|
||||
return process.exit(1);
|
||||
}
|
||||
return process.exit(0);
|
||||
});
|
File diff suppressed because one or more lines are too long
|
@ -1,353 +0,0 @@
|
|||
SET UNIQUE_CHECKS=0;
|
||||
SET FOREIGN_KEY_CHECKS=0;
|
||||
|
||||
CREATE TABLE `attachments` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`campaign` int(11) unsigned NOT NULL,
|
||||
`filename` varchar(255) CHARACTER SET utf8mb4 NOT NULL DEFAULT '',
|
||||
`content_type` varchar(100) CHARACTER SET ascii NOT NULL DEFAULT '',
|
||||
`content` longblob,
|
||||
`size` int(11) NOT NULL,
|
||||
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `campaign` (`campaign`),
|
||||
CONSTRAINT `attachments_ibfk_1` FOREIGN KEY (`campaign`) REFERENCES `campaigns` (`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
CREATE TABLE `campaign` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`list` int(11) unsigned NOT NULL,
|
||||
`segment` int(11) unsigned NOT NULL,
|
||||
`subscription` int(11) unsigned NOT NULL,
|
||||
`status` tinyint(4) unsigned NOT NULL DEFAULT '0',
|
||||
`response` varchar(255) DEFAULT NULL,
|
||||
`response_id` varchar(255) CHARACTER SET ascii DEFAULT NULL,
|
||||
`updated` timestamp NULL DEFAULT NULL,
|
||||
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `list` (`list`,`segment`,`subscription`),
|
||||
KEY `created` (`created`),
|
||||
KEY `response_id` (`response_id`),
|
||||
KEY `status_index` (`status`),
|
||||
KEY `subscription_index` (`subscription`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
CREATE TABLE `campaign_tracker` (
|
||||
`list` int(11) unsigned NOT NULL,
|
||||
`subscriber` int(11) unsigned NOT NULL,
|
||||
`link` int(11) NOT NULL,
|
||||
`ip` varchar(100) CHARACTER SET ascii DEFAULT NULL,
|
||||
`device_type` varchar(50) DEFAULT NULL,
|
||||
`country` varchar(2) CHARACTER SET ascii DEFAULT NULL,
|
||||
`count` int(11) unsigned NOT NULL DEFAULT '1',
|
||||
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`list`,`subscriber`,`link`),
|
||||
KEY `created_index` (`created`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
CREATE TABLE `campaigns` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`cid` varchar(255) CHARACTER SET ascii NOT NULL,
|
||||
`type` tinyint(4) unsigned NOT NULL DEFAULT '1',
|
||||
`parent` int(11) unsigned DEFAULT NULL,
|
||||
`name` varchar(255) NOT NULL DEFAULT '',
|
||||
`description` text,
|
||||
`list` int(11) unsigned NOT NULL,
|
||||
`segment` int(11) unsigned DEFAULT NULL,
|
||||
`template` int(11) unsigned NOT NULL,
|
||||
`source_url` varchar(255) CHARACTER SET ascii DEFAULT NULL,
|
||||
`editor_name` varchar(50) DEFAULT '',
|
||||
`editor_data` longtext,
|
||||
`last_check` timestamp NULL DEFAULT NULL,
|
||||
`check_status` varchar(255) DEFAULT NULL,
|
||||
`from` varchar(255) DEFAULT '',
|
||||
`address` varchar(255) DEFAULT '',
|
||||
`reply_to` varchar(255) DEFAULT '',
|
||||
`subject` varchar(255) DEFAULT '',
|
||||
`html` longtext,
|
||||
`html_prepared` longtext,
|
||||
`text` longtext,
|
||||
`status` tinyint(4) unsigned NOT NULL DEFAULT '1',
|
||||
`tracking_disabled` tinyint(4) unsigned NOT NULL DEFAULT '0',
|
||||
`scheduled` timestamp NULL DEFAULT NULL,
|
||||
`status_change` timestamp NULL DEFAULT NULL,
|
||||
`delivered` int(11) unsigned NOT NULL DEFAULT '0',
|
||||
`opened` int(11) unsigned NOT NULL DEFAULT '0',
|
||||
`clicks` int(11) unsigned NOT NULL DEFAULT '0',
|
||||
`unsubscribed` int(11) unsigned NOT NULL DEFAULT '0',
|
||||
`bounced` int(1) unsigned NOT NULL DEFAULT '0',
|
||||
`complained` int(1) unsigned NOT NULL DEFAULT '0',
|
||||
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `cid` (`cid`),
|
||||
KEY `name` (`name`(191)),
|
||||
KEY `status` (`status`),
|
||||
KEY `schedule_index` (`scheduled`),
|
||||
KEY `type_index` (`type`),
|
||||
KEY `parent_index` (`parent`),
|
||||
KEY `check_index` (`last_check`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
CREATE TABLE `confirmations` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`cid` varchar(255) CHARACTER SET ascii NOT NULL,
|
||||
`list` int(11) unsigned NOT NULL,
|
||||
`email` varchar(255) NOT NULL,
|
||||
`opt_in_ip` varchar(100) DEFAULT NULL,
|
||||
`data` text NOT NULL,
|
||||
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `cid` (`cid`),
|
||||
KEY `list` (`list`),
|
||||
CONSTRAINT `confirmations_ibfk_1` FOREIGN KEY (`list`) REFERENCES `lists` (`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
CREATE TABLE `custom_fields` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`list` int(11) unsigned NOT NULL,
|
||||
`name` varchar(255) DEFAULT '',
|
||||
`key` varchar(100) CHARACTER SET ascii NOT NULL,
|
||||
`default_value` varchar(255) DEFAULT NULL,
|
||||
`type` varchar(255) CHARACTER SET ascii NOT NULL DEFAULT '',
|
||||
`group` int(11) unsigned DEFAULT NULL,
|
||||
`group_template` text,
|
||||
`column` varchar(255) CHARACTER SET ascii DEFAULT NULL,
|
||||
`visible` tinyint(4) unsigned NOT NULL DEFAULT '1',
|
||||
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `list` (`list`,`column`),
|
||||
KEY `list_2` (`list`),
|
||||
CONSTRAINT `custom_fields_ibfk_1` FOREIGN KEY (`list`) REFERENCES `lists` (`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
CREATE TABLE `custom_forms` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`list` int(11) unsigned NOT NULL,
|
||||
`name` varchar(255) DEFAULT '',
|
||||
`description` text,
|
||||
`fields_shown_on_subscribe` varchar(255) DEFAULT '',
|
||||
`fields_shown_on_manage` varchar(255) DEFAULT '',
|
||||
`layout` longtext,
|
||||
`form_input_style` longtext,
|
||||
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `list` (`list`),
|
||||
CONSTRAINT `custom_forms_ibfk_1` FOREIGN KEY (`list`) REFERENCES `lists` (`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
CREATE TABLE `custom_forms_data` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`form` int(11) unsigned NOT NULL,
|
||||
`data_key` varchar(255) DEFAULT '',
|
||||
`data_value` longtext,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `form` (`form`),
|
||||
CONSTRAINT `custom_forms_data_ibfk_1` FOREIGN KEY (`form`) REFERENCES `custom_forms` (`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
CREATE TABLE `import_failed` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`import` int(11) unsigned NOT NULL,
|
||||
`email` varchar(255) NOT NULL DEFAULT '',
|
||||
`reason` varchar(255) DEFAULT NULL,
|
||||
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `import` (`import`),
|
||||
CONSTRAINT `import_failed_ibfk_1` FOREIGN KEY (`import`) REFERENCES `importer` (`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
CREATE TABLE `importer` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`list` int(11) unsigned NOT NULL,
|
||||
`type` tinyint(4) unsigned NOT NULL DEFAULT '1',
|
||||
`path` varchar(255) NOT NULL DEFAULT '',
|
||||
`size` int(11) unsigned NOT NULL DEFAULT '0',
|
||||
`delimiter` varchar(1) CHARACTER SET ascii NOT NULL DEFAULT ',',
|
||||
`emailcheck` tinyint(4) unsigned NOT NULL DEFAULT '1',
|
||||
`status` tinyint(4) unsigned NOT NULL DEFAULT '0',
|
||||
`error` varchar(255) DEFAULT NULL,
|
||||
`processed` int(11) unsigned NOT NULL DEFAULT '0',
|
||||
`new` int(11) unsigned NOT NULL DEFAULT '0',
|
||||
`failed` int(11) unsigned NOT NULL DEFAULT '0',
|
||||
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`mapping` text NOT NULL,
|
||||
`finished` timestamp NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `list` (`list`),
|
||||
CONSTRAINT `importer_ibfk_1` FOREIGN KEY (`list`) REFERENCES `lists` (`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
CREATE TABLE `links` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`cid` varchar(255) CHARACTER SET ascii NOT NULL DEFAULT '',
|
||||
`campaign` int(11) unsigned NOT NULL,
|
||||
`url` varchar(255) CHARACTER SET ascii NOT NULL DEFAULT '',
|
||||
`clicks` int(11) unsigned NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `cid` (`cid`),
|
||||
UNIQUE KEY `campaign_2` (`campaign`,`url`),
|
||||
KEY `campaign` (`campaign`),
|
||||
CONSTRAINT `links_ibfk_1` FOREIGN KEY (`campaign`) REFERENCES `campaigns` (`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
CREATE TABLE `lists` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`cid` varchar(255) CHARACTER SET ascii NOT NULL,
|
||||
`default_form` int(11) unsigned DEFAULT NULL,
|
||||
`name` varchar(255) NOT NULL DEFAULT '',
|
||||
`description` text,
|
||||
`subscribers` int(11) unsigned DEFAULT '0',
|
||||
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `cid` (`cid`),
|
||||
KEY `name` (`name`(191))
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
CREATE TABLE `queued` (
|
||||
`campaign` int(11) unsigned NOT NULL,
|
||||
`list` int(11) unsigned NOT NULL,
|
||||
`subscriber` int(11) unsigned NOT NULL,
|
||||
`source` varchar(255) DEFAULT NULL,
|
||||
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`campaign`,`list`,`subscriber`),
|
||||
KEY `created` (`created`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
CREATE TABLE `rss` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`parent` int(11) unsigned NOT NULL,
|
||||
`guid` varchar(255) NOT NULL DEFAULT '',
|
||||
`pubdate` timestamp NULL DEFAULT NULL,
|
||||
`campaign` int(11) unsigned DEFAULT NULL,
|
||||
`found` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `parent_2` (`parent`,`guid`),
|
||||
KEY `parent` (`parent`),
|
||||
CONSTRAINT `rss_ibfk_1` FOREIGN KEY (`parent`) REFERENCES `campaigns` (`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
CREATE TABLE `segment_rules` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`segment` int(11) unsigned NOT NULL,
|
||||
`column` varchar(255) CHARACTER SET ascii NOT NULL DEFAULT '',
|
||||
`value` varchar(255) NOT NULL DEFAULT '',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `segment` (`segment`),
|
||||
CONSTRAINT `segment_rules_ibfk_1` FOREIGN KEY (`segment`) REFERENCES `segments` (`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
CREATE TABLE `segments` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`list` int(11) unsigned NOT NULL,
|
||||
`name` varchar(255) NOT NULL DEFAULT '',
|
||||
`type` tinyint(4) unsigned NOT NULL,
|
||||
`created` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `list` (`list`),
|
||||
KEY `name` (`name`(191)),
|
||||
CONSTRAINT `segments_ibfk_1` FOREIGN KEY (`list`) REFERENCES `lists` (`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
CREATE TABLE `settings` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`key` varchar(255) CHARACTER SET ascii NOT NULL DEFAULT '',
|
||||
`value` text NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `key` (`key`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=41 DEFAULT CHARSET=utf8mb4;
|
||||
INSERT INTO `settings` (`id`, `key`, `value`) VALUES (1,'smtp_hostname','smtp-pulse.com');
|
||||
INSERT INTO `settings` (`id`, `key`, `value`) VALUES (2,'smtp_port','465');
|
||||
INSERT INTO `settings` (`id`, `key`, `value`) VALUES (3,'smtp_encryption','TLS');
|
||||
INSERT INTO `settings` (`id`, `key`, `value`) VALUES (4,'smtp_user','');
|
||||
INSERT INTO `settings` (`id`, `key`, `value`) VALUES (5,'smtp_pass','');
|
||||
INSERT INTO `settings` (`id`, `key`, `value`) VALUES (6,'service_url','http://localhost:3000/');
|
||||
INSERT INTO `settings` (`id`, `key`, `value`) VALUES (7,'admin_email','admin@example.com');
|
||||
INSERT INTO `settings` (`id`, `key`, `value`) VALUES (8,'smtp_max_connections','5');
|
||||
INSERT INTO `settings` (`id`, `key`, `value`) VALUES (9,'smtp_max_messages','100');
|
||||
INSERT INTO `settings` (`id`, `key`, `value`) VALUES (10,'smtp_log','');
|
||||
INSERT INTO `settings` (`id`, `key`, `value`) VALUES (11,'default_sender','My Awesome Company');
|
||||
INSERT INTO `settings` (`id`, `key`, `value`) VALUES (12,'default_postaddress','1234 Main Street');
|
||||
INSERT INTO `settings` (`id`, `key`, `value`) VALUES (13,'default_from','My Awesome Company');
|
||||
INSERT INTO `settings` (`id`, `key`, `value`) VALUES (14,'default_address','admin@example.com');
|
||||
INSERT INTO `settings` (`id`, `key`, `value`) VALUES (15,'default_subject','Test message');
|
||||
INSERT INTO `settings` (`id`, `key`, `value`) VALUES (16,'default_homepage','http://localhost:3000/');
|
||||
INSERT INTO `settings` (`id`, `key`, `value`) VALUES (17,'db_schema_version','24');
|
||||
CREATE TABLE `subscription` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`cid` varchar(255) CHARACTER SET ascii NOT NULL,
|
||||
`email` varchar(255) CHARACTER SET utf8 NOT NULL DEFAULT '',
|
||||
`opt_in_ip` varchar(100) DEFAULT NULL,
|
||||
`opt_in_country` varchar(2) DEFAULT NULL,
|
||||
`tz` varchar(100) CHARACTER SET ascii DEFAULT NULL,
|
||||
`imported` int(11) unsigned DEFAULT NULL,
|
||||
`status` tinyint(4) unsigned NOT NULL DEFAULT '1',
|
||||
`is_test` tinyint(4) unsigned NOT NULL DEFAULT '0',
|
||||
`status_change` timestamp NULL DEFAULT NULL,
|
||||
`latest_open` timestamp NULL DEFAULT NULL,
|
||||
`latest_click` timestamp NULL DEFAULT NULL,
|
||||
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`first_name` varchar(255) DEFAULT NULL,
|
||||
`last_name` varchar(255) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `email` (`email`),
|
||||
UNIQUE KEY `cid` (`cid`),
|
||||
KEY `status` (`status`),
|
||||
KEY `first_name` (`first_name`(191)),
|
||||
KEY `last_name` (`last_name`(191)),
|
||||
KEY `subscriber_tz` (`tz`),
|
||||
KEY `is_test` (`is_test`),
|
||||
KEY `latest_open` (`latest_open`),
|
||||
KEY `latest_click` (`latest_click`),
|
||||
KEY `created` (`created`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
CREATE TABLE `templates` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(255) NOT NULL DEFAULT '',
|
||||
`description` text,
|
||||
`editor_name` varchar(50) DEFAULT '',
|
||||
`editor_data` longtext,
|
||||
`html` longtext,
|
||||
`text` longtext,
|
||||
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `name` (`name`(191))
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
CREATE TABLE `trigger` (
|
||||
`list` int(11) unsigned NOT NULL,
|
||||
`subscription` int(11) unsigned NOT NULL,
|
||||
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`list`,`subscription`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
CREATE TABLE `triggers` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(255) NOT NULL DEFAULT '',
|
||||
`description` text,
|
||||
`enabled` tinyint(4) unsigned NOT NULL DEFAULT '1',
|
||||
`list` int(11) unsigned NOT NULL,
|
||||
`source_campaign` int(11) unsigned DEFAULT NULL,
|
||||
`rule` varchar(255) CHARACTER SET ascii NOT NULL DEFAULT 'column',
|
||||
`column` varchar(255) CHARACTER SET ascii DEFAULT NULL,
|
||||
`seconds` int(11) NOT NULL DEFAULT '0',
|
||||
`dest_campaign` int(11) unsigned DEFAULT NULL,
|
||||
`count` int(11) unsigned NOT NULL DEFAULT '0',
|
||||
`last_check` timestamp NULL DEFAULT NULL,
|
||||
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `name` (`name`(191)),
|
||||
KEY `source_campaign` (`source_campaign`),
|
||||
KEY `dest_campaign` (`dest_campaign`),
|
||||
KEY `list` (`list`),
|
||||
KEY `column` (`column`),
|
||||
KEY `active` (`enabled`),
|
||||
KEY `last_check` (`last_check`),
|
||||
CONSTRAINT `triggers_ibfk_1` FOREIGN KEY (`list`) REFERENCES `lists` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
CREATE TABLE `tzoffset` (
|
||||
`tz` varchar(100) NOT NULL DEFAULT '',
|
||||
`offset` int(11) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`tz`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=ascii;
|
||||
CREATE TABLE `users` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`username` varchar(255) NOT NULL DEFAULT '',
|
||||
`password` varchar(255) NOT NULL DEFAULT '',
|
||||
`email` varchar(255) CHARACTER SET utf8 DEFAULT NULL,
|
||||
`access_token` varchar(40) DEFAULT NULL,
|
||||
`reset_token` varchar(255) CHARACTER SET ascii DEFAULT NULL,
|
||||
`reset_expire` timestamp NULL DEFAULT NULL,
|
||||
`created` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `email` (`email`),
|
||||
KEY `username` (`username`(191)),
|
||||
KEY `reset` (`reset_token`),
|
||||
KEY `check_reset` (`username`(191),`reset_token`,`reset_expire`),
|
||||
KEY `token_index` (`access_token`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4;
|
||||
INSERT INTO `users` (`id`, `username`, `password`, `email`, `access_token`, `reset_token`, `reset_expire`, `created`) VALUES (1,'admin','$2a$10$mzKU71G62evnGB2PvQA4k..Wf9jASk.c7a8zRMHh6qQVjYJ2r/g/K','admin@example.com',NULL,NULL,NULL,NOW());
|
||||
|
||||
SET UNIQUE_CHECKS=1;
|
||||
SET FOREIGN_KEY_CHECKS=1;
|
|
@ -1,25 +0,0 @@
|
|||
# Header section
|
||||
# Define incrementing schema version number
|
||||
SET @schema_version = '1';
|
||||
|
||||
# Upgrade script section
|
||||
CREATE TABLE `import_failed` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`import` int(11) unsigned NOT NULL,
|
||||
`email` varchar(255) NOT NULL DEFAULT '',
|
||||
`reason` varchar(255) DEFAULT NULL,
|
||||
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `import` (`import`),
|
||||
CONSTRAINT `import_failed_ibfk_1` FOREIGN KEY (`import`) REFERENCES `importer` (`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
# Temporary additions
|
||||
UPDATE `settings` SET `value`='smtp-pulse.com' WHERE `key`='smtp_hostname' LIMIT 1;
|
||||
UPDATE `settings` SET `value`='' WHERE `key`='smtp_user' LIMIT 1;
|
||||
UPDATE `settings` SET `value`='' WHERE `key`='smtp_pass' LIMIT 1;
|
||||
|
||||
# Footer section
|
||||
LOCK TABLES `settings` WRITE;
|
||||
INSERT INTO `settings` (`key`, `value`) VALUES('db_schema_version', @schema_version) ON DUPLICATE KEY UPDATE `value`=@schema_version;
|
||||
UNLOCK TABLES;
|
|
@ -1,12 +0,0 @@
|
|||
# Header section
|
||||
# Define incrementing schema version number
|
||||
SET @schema_version = '2';
|
||||
|
||||
# Adds new column 'failed' to importer table. Includes the count of failed addresses for an import
|
||||
ALTER TABLE importer ADD COLUMN `failed` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `processed`;
|
||||
ALTER TABLE importer ADD COLUMN `new` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `processed`;
|
||||
|
||||
# Footer section
|
||||
LOCK TABLES `settings` WRITE;
|
||||
INSERT INTO `settings` (`key`, `value`) VALUES('db_schema_version', @schema_version) ON DUPLICATE KEY UPDATE `value`=@schema_version;
|
||||
UNLOCK TABLES;
|
|
@ -1,12 +0,0 @@
|
|||
# Header section
|
||||
# Define incrementing schema version number
|
||||
SET @schema_version = '3';
|
||||
|
||||
# Adds new column 'scheduled' to campaigns table. Indicates when the sending should actually start
|
||||
ALTER TABLE `campaigns` ADD COLUMN `scheduled` timestamp NULL DEFAULT NULL AFTER `status`;
|
||||
CREATE INDEX schedule_index ON `campaigns` (`scheduled`);
|
||||
|
||||
# Footer section
|
||||
LOCK TABLES `settings` WRITE;
|
||||
INSERT INTO `settings` (`key`, `value`) VALUES('db_schema_version', @schema_version) ON DUPLICATE KEY UPDATE `value`=@schema_version;
|
||||
UNLOCK TABLES;
|
|
@ -1,12 +0,0 @@
|
|||
# Header section
|
||||
# Define incrementing schema version number
|
||||
SET @schema_version = '4';
|
||||
|
||||
# Adds new column 'template_url' to campaigns table
|
||||
# Indicates that this campaign should fetch message content from this URL
|
||||
ALTER TABLE `campaigns` ADD COLUMN `template_url` varchar(255) CHARACTER SET ascii DEFAULT NULL AFTER `template`;
|
||||
|
||||
# Footer section
|
||||
LOCK TABLES `settings` WRITE;
|
||||
INSERT INTO `settings` (`key`, `value`) VALUES('db_schema_version', @schema_version) ON DUPLICATE KEY UPDATE `value`=@schema_version;
|
||||
UNLOCK TABLES;
|
|
@ -1,17 +0,0 @@
|
|||
# Header section
|
||||
# Define incrementing schema version number
|
||||
SET @schema_version = '5';
|
||||
|
||||
-- {{#each tables.subscription}}
|
||||
|
||||
# Adds new column 'tz' to subscriptions table
|
||||
# Indicates subscriber time zone, use UTC as default
|
||||
ALTER TABLE `{{this}}` ADD COLUMN `tz` varchar(100) CHARACTER SET ascii DEFAULT NULL AFTER `opt_in_country`;
|
||||
CREATE INDEX subscriber_tz ON `{{this}}` (`tz`);
|
||||
|
||||
-- {{/each}}
|
||||
|
||||
# Footer section
|
||||
LOCK TABLES `settings` WRITE;
|
||||
INSERT INTO `settings` (`key`, `value`) VALUES('db_schema_version', @schema_version) ON DUPLICATE KEY UPDATE `value`=@schema_version;
|
||||
UNLOCK TABLES;
|
|
@ -1,16 +0,0 @@
|
|||
# Header section
|
||||
# Define incrementing schema version number
|
||||
SET @schema_version = '6';
|
||||
|
||||
# Creates table to store timezone offsets required to calculate correct start time for sending
|
||||
# messages to specific subscribers
|
||||
CREATE TABLE `tzoffset` (
|
||||
`tz` varchar(100) CHARACTER SET ascii NOT NULL DEFAULT '',
|
||||
`offset` int(11) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`tz`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=ascii;
|
||||
|
||||
# Footer section
|
||||
LOCK TABLES `settings` WRITE;
|
||||
INSERT INTO `settings` (`key`, `value`) VALUES('db_schema_version', @schema_version) ON DUPLICATE KEY UPDATE `value`=@schema_version;
|
||||
UNLOCK TABLES;
|
|
@ -1,14 +0,0 @@
|
|||
# Header section
|
||||
# Define incrementing schema version number
|
||||
SET @schema_version = '7';
|
||||
|
||||
# Rename template_url to source_url in order to use this field for different kind of urls, eg. for RSS url
|
||||
ALTER TABLE `campaigns` CHANGE COLUMN `template_url` `source_url` varchar(255) CHARACTER SET ascii DEFAULT NULL;
|
||||
# Add new column type that defines what kind of campaign is it. A normal campaign, (1), RSS (2) or drip (3)
|
||||
ALTER TABLE `campaigns` ADD COLUMN `type` tinyint(4) unsigned NOT NULL DEFAULT '1' AFTER `cid`;
|
||||
CREATE INDEX type_index ON `campaigns` (`type`);
|
||||
|
||||
# Footer section
|
||||
LOCK TABLES `settings` WRITE;
|
||||
INSERT INTO `settings` (`key`, `value`) VALUES('db_schema_version', @schema_version) ON DUPLICATE KEY UPDATE `value`=@schema_version;
|
||||
UNLOCK TABLES;
|
|
@ -1,28 +0,0 @@
|
|||
# Header section
|
||||
# Define incrementing schema version number
|
||||
SET @schema_version = '8';
|
||||
|
||||
# Create new table to store RSS entries for RSS campaigns
|
||||
CREATE TABLE `rss` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`parent` int(11) unsigned NOT NULL,
|
||||
`guid` varchar(255) NOT NULL DEFAULT '',
|
||||
`pubdate` timestamp NULL DEFAULT NULL,
|
||||
`campaign` int(11) unsigned DEFAULT NULL,
|
||||
`found` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `parent_2` (`parent`,`guid`),
|
||||
KEY `parent` (`parent`),
|
||||
CONSTRAINT `rss_ibfk_1` FOREIGN KEY (`parent`) REFERENCES `campaigns` (`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
ALTER TABLE `campaigns` ADD COLUMN `parent` int(11) unsigned DEFAULT NULL AFTER `type`;
|
||||
CREATE INDEX parent_index ON `campaigns` (`parent`);
|
||||
ALTER TABLE `campaigns` ADD COLUMN `last_check` timestamp NULL DEFAULT NULL AFTER `source_url`;
|
||||
ALTER TABLE `campaigns` ADD COLUMN `check_status` varchar(255) NULL DEFAULT NULL AFTER `last_check`;
|
||||
CREATE INDEX check_index ON `campaigns` (`last_check`);
|
||||
ALTER TABLE `campaigns` ADD COLUMN `html_prepared` text AFTER `html`;
|
||||
|
||||
# Footer section
|
||||
LOCK TABLES `settings` WRITE;
|
||||
INSERT INTO `settings` (`key`, `value`) VALUES('db_schema_version', @schema_version) ON DUPLICATE KEY UPDATE `value`=@schema_version;
|
||||
UNLOCK TABLES;
|
|
@ -1,12 +0,0 @@
|
|||
# Header section
|
||||
# Define incrementing schema version number
|
||||
SET @schema_version = '9';
|
||||
|
||||
# Adds a column for static access tokens to be used in API authentication
|
||||
ALTER TABLE `users` ADD COLUMN `access_token` varchar(40) NULL DEFAULT NULL AFTER `email`;
|
||||
CREATE INDEX token_index ON `users` (`access_token`);
|
||||
|
||||
# Footer section
|
||||
LOCK TABLES `settings` WRITE;
|
||||
INSERT INTO `settings` (`key`, `value`) VALUES('db_schema_version', @schema_version) ON DUPLICATE KEY UPDATE `value`=@schema_version;
|
||||
UNLOCK TABLES;
|
|
@ -1,17 +0,0 @@
|
|||
# Header section
|
||||
# Define incrementing schema version number
|
||||
SET @schema_version = '10';
|
||||
|
||||
-- {{#each tables.campaign_tracker}}
|
||||
|
||||
# Adds new column 'created' to campaign tracker table
|
||||
# Indicates when a subscriber first clicked a link or opened the message
|
||||
ALTER TABLE `{{this}}` ADD COLUMN `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP AFTER `count`;
|
||||
CREATE INDEX created_index ON `{{this}}` (`created`);
|
||||
|
||||
-- {{/each}}
|
||||
|
||||
# Footer section
|
||||
LOCK TABLES `settings` WRITE;
|
||||
INSERT INTO `settings` (`key`, `value`) VALUES('db_schema_version', @schema_version) ON DUPLICATE KEY UPDATE `value`=@schema_version;
|
||||
UNLOCK TABLES;
|
|
@ -1,15 +0,0 @@
|
|||
# Header section
|
||||
# Define incrementing schema version number
|
||||
SET @schema_version = '11';
|
||||
|
||||
-- {{#each tables.campaign}}
|
||||
|
||||
# Adds new index for 'status' on campaign messages table
|
||||
CREATE INDEX status_index ON `{{this}}` (`status`);
|
||||
|
||||
-- {{/each}}
|
||||
|
||||
# Footer section
|
||||
LOCK TABLES `settings` WRITE;
|
||||
INSERT INTO `settings` (`key`, `value`) VALUES('db_schema_version', @schema_version) ON DUPLICATE KEY UPDATE `value`=@schema_version;
|
||||
UNLOCK TABLES;
|
|
@ -1,16 +0,0 @@
|
|||
# Header section
|
||||
# Define incrementing schema version number
|
||||
SET @schema_version = '12';
|
||||
|
||||
# Message source could include inlined images which might overflow on the default 65k field length
|
||||
ALTER TABLE `campaigns` MODIFY `html` LONGTEXT;
|
||||
ALTER TABLE `campaigns` MODIFY `html_prepared` LONGTEXT;
|
||||
ALTER TABLE `campaigns` MODIFY `text` LONGTEXT;
|
||||
|
||||
ALTER TABLE `templates` MODIFY `html` LONGTEXT;
|
||||
ALTER TABLE `templates` MODIFY `text` LONGTEXT;
|
||||
|
||||
# Footer section
|
||||
LOCK TABLES `settings` WRITE;
|
||||
INSERT INTO `settings` (`key`, `value`) VALUES('db_schema_version', @schema_version) ON DUPLICATE KEY UPDATE `value`=@schema_version;
|
||||
UNLOCK TABLES;
|
|
@ -1,15 +0,0 @@
|
|||
# Header section
|
||||
# Define incrementing schema version number
|
||||
SET @schema_version = '13';
|
||||
|
||||
-- {{#each tables.campaign}}
|
||||
|
||||
# Adds separate index for 'subscription' on campaign messages table
|
||||
CREATE INDEX subscription_index ON `{{this}}` (`subscription`);
|
||||
|
||||
-- {{/each}}
|
||||
|
||||
# Footer section
|
||||
LOCK TABLES `settings` WRITE;
|
||||
INSERT INTO `settings` (`key`, `value`) VALUES('db_schema_version', @schema_version) ON DUPLICATE KEY UPDATE `value`=@schema_version;
|
||||
UNLOCK TABLES;
|
|
@ -1,17 +0,0 @@
|
|||
# Header section
|
||||
# Define incrementing schema version number
|
||||
SET @schema_version = '14';
|
||||
|
||||
-- {{#each tables.subscription}}
|
||||
|
||||
# Adds new column 'tz' to subscriptions table
|
||||
# Indicates subscriber time zone, use UTC as default
|
||||
ALTER TABLE `{{this}}` ADD COLUMN `is_test` tinyint(4) unsigned NOT NULL DEFAULT '0' AFTER `status`;
|
||||
CREATE INDEX is_test ON `{{this}}` (`is_test`);
|
||||
|
||||
-- {{/each}}
|
||||
|
||||
# Footer section
|
||||
LOCK TABLES `settings` WRITE;
|
||||
INSERT INTO `settings` (`key`, `value`) VALUES('db_schema_version', @schema_version) ON DUPLICATE KEY UPDATE `value`=@schema_version;
|
||||
UNLOCK TABLES;
|
|
@ -1,59 +0,0 @@
|
|||
# Header section
|
||||
# Define incrementing schema version number
|
||||
SET @schema_version = '15';
|
||||
|
||||
# table for trigger definitions
|
||||
CREATE TABLE `triggers` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(255) NOT NULL DEFAULT '',
|
||||
`description` text,
|
||||
`enabled` tinyint(4) unsigned NOT NULL DEFAULT '1',
|
||||
`list` int(11) unsigned NOT NULL,
|
||||
`source_campaign` int(11) unsigned DEFAULT NULL,
|
||||
`rule` varchar(255) CHARACTER SET ascii NOT NULL DEFAULT 'column',
|
||||
`column` varchar(255) CHARACTER SET ascii DEFAULT NULL,
|
||||
`seconds` int(11) NOT NULL DEFAULT '0',
|
||||
`dest_campaign` int(11) unsigned DEFAULT NULL,
|
||||
`last_check` timestamp NULL DEFAULT NULL,
|
||||
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `name` (`name`(191)),
|
||||
KEY `source_campaign` (`source_campaign`),
|
||||
KEY `dest_campaign` (`dest_campaign`),
|
||||
KEY `list` (`list`),
|
||||
KEY `column` (`column`),
|
||||
KEY `active` (`enabled`),
|
||||
KEY `last_check` (`last_check`),
|
||||
CONSTRAINT `triggers_ibfk_1` FOREIGN KEY (`list`) REFERENCES `lists` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
# base table for triggered matches
|
||||
CREATE TABLE `trigger` (
|
||||
`list` int(11) unsigned NOT NULL,
|
||||
`subscription` int(11) unsigned NOT NULL,
|
||||
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`list`,`subscription`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
# table for yet queued messages ready to be sent
|
||||
CREATE TABLE `queued` (
|
||||
`campaign` int(11) unsigned NOT NULL,
|
||||
`list` int(11) unsigned NOT NULL,
|
||||
`subscriber` int(11) unsigned NOT NULL,
|
||||
`source` varchar(255) DEFAULT NULL,
|
||||
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`campaign`,`list`,`subscriber`),
|
||||
KEY `created` (`created`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- {{#each tables.subscription}}
|
||||
# Adds indexes for triggers
|
||||
CREATE INDEX latest_open ON `{{this}}` (`latest_open`);
|
||||
CREATE INDEX latest_click ON `{{this}}` (`latest_click`);
|
||||
CREATE INDEX created ON `{{this}}` (`created`);
|
||||
-- {{/each}}
|
||||
|
||||
# Footer section
|
||||
LOCK TABLES `settings` WRITE;
|
||||
INSERT INTO `settings` (`key`, `value`) VALUES('db_schema_version', @schema_version) ON DUPLICATE KEY UPDATE `value`=@schema_version;
|
||||
UNLOCK TABLES;
|
|
@ -1,10 +0,0 @@
|
|||
# Header section
|
||||
# Define incrementing schema version number
|
||||
SET @schema_version = '16';
|
||||
|
||||
ALTER TABLE `triggers` ADD COLUMN `count` int(11) unsigned NOT NULL DEFAULT '0' AFTER `dest_campaign`;
|
||||
|
||||
# Footer section
|
||||
LOCK TABLES `settings` WRITE;
|
||||
INSERT INTO `settings` (`key`, `value`) VALUES('db_schema_version', @schema_version) ON DUPLICATE KEY UPDATE `value`=@schema_version;
|
||||
UNLOCK TABLES;
|
|
@ -1,11 +0,0 @@
|
|||
# Header section
|
||||
# Define incrementing schema version number
|
||||
SET @schema_version = '17';
|
||||
|
||||
# Add template field for group elements
|
||||
ALTER TABLE `custom_fields` ADD COLUMN `group_template` text AFTER `group`;
|
||||
|
||||
# Footer section
|
||||
LOCK TABLES `settings` WRITE;
|
||||
INSERT INTO `settings` (`key`, `value`) VALUES('db_schema_version', @schema_version) ON DUPLICATE KEY UPDATE `value`=@schema_version;
|
||||
UNLOCK TABLES;
|
|
@ -1,12 +0,0 @@
|
|||
# Header section
|
||||
# Define incrementing schema version number
|
||||
SET @schema_version = '18';
|
||||
|
||||
# Add template field for group elements
|
||||
ALTER TABLE `campaigns` ADD COLUMN `tracking_disabled` tinyint(4) unsigned NOT NULL DEFAULT '0' AFTER `status`;
|
||||
ALTER TABLE `confirmations` ADD COLUMN `opt_in_ip` varchar(100) DEFAULT NULL AFTER `email`;
|
||||
|
||||
# Footer section
|
||||
LOCK TABLES `settings` WRITE;
|
||||
INSERT INTO `settings` (`key`, `value`) VALUES('db_schema_version', @schema_version) ON DUPLICATE KEY UPDATE `value`=@schema_version;
|
||||
UNLOCK TABLES;
|
|
@ -1,21 +0,0 @@
|
|||
# Header section
|
||||
# Define incrementing schema version number
|
||||
SET @schema_version = '19';
|
||||
|
||||
CREATE TABLE `attachments` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`campaign` int(11) unsigned NOT NULL,
|
||||
`filename` varchar(255) CHARACTER SET utf8mb4 NOT NULL DEFAULT '',
|
||||
`content_type` varchar(100) CHARACTER SET ascii NOT NULL DEFAULT '',
|
||||
`content` longblob,
|
||||
`size` int(11) NOT NULL,
|
||||
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `campaign` (`campaign`),
|
||||
CONSTRAINT `attachments_ibfk_1` FOREIGN KEY (`campaign`) REFERENCES `campaigns` (`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
# Footer section
|
||||
LOCK TABLES `settings` WRITE;
|
||||
INSERT INTO `settings` (`key`, `value`) VALUES('db_schema_version', @schema_version) ON DUPLICATE KEY UPDATE `value`=@schema_version;
|
||||
UNLOCK TABLES;
|
|
@ -1,11 +0,0 @@
|
|||
# Header section
|
||||
# Define incrementing schema version number
|
||||
SET @schema_version = '20';
|
||||
|
||||
# Add reply_to field
|
||||
ALTER TABLE `campaigns` ADD COLUMN `reply_to` varchar(255) DEFAULT '' AFTER `address`;
|
||||
|
||||
# Footer section
|
||||
LOCK TABLES `settings` WRITE;
|
||||
INSERT INTO `settings` (`key`, `value`) VALUES('db_schema_version', @schema_version) ON DUPLICATE KEY UPDATE `value`=@schema_version;
|
||||
UNLOCK TABLES;
|
|
@ -1,16 +0,0 @@
|
|||
# Header section
|
||||
# Define incrementing schema version number
|
||||
SET @schema_version = '21';
|
||||
|
||||
# Add fields editor_name, editor_data to templates
|
||||
ALTER TABLE `templates` ADD COLUMN `editor_name` varchar(50) DEFAULT '' AFTER `description`;
|
||||
ALTER TABLE `templates` ADD COLUMN `editor_data` longtext AFTER `editor_name`;
|
||||
|
||||
# Add fields editor_name, editor_data to campaigns
|
||||
ALTER TABLE `campaigns` ADD COLUMN `editor_name` varchar(50) DEFAULT '' AFTER `source_url`;
|
||||
ALTER TABLE `campaigns` ADD COLUMN `editor_data` longtext AFTER `editor_name`;
|
||||
|
||||
# Footer section
|
||||
LOCK TABLES `settings` WRITE;
|
||||
INSERT INTO `settings` (`key`, `value`) VALUES('db_schema_version', @schema_version) ON DUPLICATE KEY UPDATE `value`=@schema_version;
|
||||
UNLOCK TABLES;
|
|
@ -1,38 +0,0 @@
|
|||
# Header section
|
||||
# Define incrementing schema version number
|
||||
SET @schema_version = '22';
|
||||
|
||||
# Create table to store custom forms
|
||||
CREATE TABLE `custom_forms` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`list` int(11) unsigned NOT NULL,
|
||||
`name` varchar(255) DEFAULT '',
|
||||
`description` text,
|
||||
`fields_shown_on_subscribe` varchar(255) DEFAULT '',
|
||||
`fields_shown_on_manage` varchar(255) DEFAULT '',
|
||||
`layout` longtext,
|
||||
`form_input_style` longtext,
|
||||
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `list` (`list`),
|
||||
CONSTRAINT `custom_forms_ibfk_1` FOREIGN KEY (`list`) REFERENCES `lists` (`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
# Create table to store custom form data
|
||||
CREATE TABLE `custom_forms_data` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`form` int(11) unsigned NOT NULL,
|
||||
`data_key` varchar(255) DEFAULT '',
|
||||
`data_value` longtext,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `form` (`form`),
|
||||
CONSTRAINT `custom_forms_data_ibfk_1` FOREIGN KEY (`form`) REFERENCES `custom_forms` (`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
# Add default_form to lists
|
||||
ALTER TABLE `lists` ADD COLUMN `default_form` int(11) unsigned DEFAULT NULL AFTER `cid`;
|
||||
|
||||
# Footer section
|
||||
LOCK TABLES `settings` WRITE;
|
||||
INSERT INTO `settings` (`key`, `value`) VALUES('db_schema_version', @schema_version) ON DUPLICATE KEY UPDATE `value`=@schema_version;
|
||||
UNLOCK TABLES;
|
|
@ -1,37 +0,0 @@
|
|||
# Header section
|
||||
# Define incrementing schema version number
|
||||
SET @schema_version = '23';
|
||||
|
||||
# Add field device_type to campaign_tracker
|
||||
|
||||
# Create ALTER TABLE PROCEDURE
|
||||
DROP PROCEDURE IF EXISTS `alterbyregexp`;
|
||||
CREATE PROCEDURE `alterbyregexp` (`table_regexp` VARCHAR(255), `altertext` VARCHAR(255))
|
||||
BEGIN
|
||||
DECLARE done INT DEFAULT FALSE;
|
||||
DECLARE tbl VARCHAR(255);
|
||||
DECLARE curs CURSOR FOR SELECT table_name FROM information_schema.tables WHERE table_schema = (SELECT DATABASE()) and table_name like table_regexp;
|
||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
|
||||
OPEN curs;
|
||||
|
||||
read_loop: LOOP
|
||||
FETCH curs INTO tbl;
|
||||
IF done THEN
|
||||
LEAVE read_loop;
|
||||
END IF;
|
||||
SET @query = CONCAT('ALTER TABLE `', tbl, '`' , altertext);
|
||||
PREPARE stmt FROM @query;
|
||||
EXECUTE stmt;
|
||||
DEALLOCATE PREPARE stmt;
|
||||
END LOOP;
|
||||
CLOSE curs;
|
||||
END;
|
||||
|
||||
# Add field device_type to campaign_tracker
|
||||
CALL alterbyregexp('campaign\_tracker%', 'ADD COLUMN `device_type` varchar(50) DEFAULT NULL AFTER `ip`');
|
||||
DROP PROCEDURE IF EXISTS `alterbyregexp`;
|
||||
|
||||
# Footer section
|
||||
LOCK TABLES `settings` WRITE;
|
||||
INSERT INTO `settings` (`key`, `value`) VALUES('db_schema_version', @schema_version) ON DUPLICATE KEY UPDATE `value`=@schema_version;
|
||||
UNLOCK TABLES;
|
|
@ -1,11 +0,0 @@
|
|||
# Header section
|
||||
# Define incrementing schema version number
|
||||
SET @schema_version = '24';
|
||||
|
||||
# Add field
|
||||
ALTER TABLE `importer` ADD COLUMN `emailcheck` tinyint(4) unsigned DEFAULT 1 NOT NULL AFTER `delimiter`;
|
||||
|
||||
# Footer section
|
||||
LOCK TABLES `settings` WRITE;
|
||||
INSERT INTO `settings` (`key`, `value`) VALUES('db_schema_version', @schema_version) ON DUPLICATE KEY UPDATE `value`=@schema_version;
|
||||
UNLOCK TABLES;
|
|
@ -1,17 +0,0 @@
|
|||
# Header section
|
||||
# Define incrementing schema version number
|
||||
SET @schema_version = '25';
|
||||
|
||||
# Create table to store global blacklist
|
||||
CREATE TABLE `blacklist` (
|
||||
`email` varchar(191) NOT NULL,
|
||||
PRIMARY KEY (`email`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
#Alter table campaigns
|
||||
ALTER TABLE `campaigns` ADD COLUMN `blacklisted` int(11) unsigned NOT NULL DEFAULT '0' AFTER `delivered`;
|
||||
|
||||
# Footer section
|
||||
LOCK TABLES `settings` WRITE;
|
||||
INSERT INTO `settings` (`key`, `value`) VALUES('db_schema_version', @schema_version) ON DUPLICATE KEY UPDATE `value`=@schema_version;
|
||||
UNLOCK TABLES;
|
|
@ -1,11 +0,0 @@
|
|||
# Header section
|
||||
# Define incrementing schema version number
|
||||
SET @schema_version = '26';
|
||||
|
||||
# Add field
|
||||
ALTER TABLE `lists` ADD COLUMN `public_subscribe` tinyint(1) unsigned DEFAULT 1 NOT NULL AFTER `created`;
|
||||
|
||||
# Footer section
|
||||
LOCK TABLES `settings` WRITE;
|
||||
INSERT INTO `settings` (`key`, `value`) VALUES('db_schema_version', @schema_version) ON DUPLICATE KEY UPDATE `value`=@schema_version;
|
||||
UNLOCK TABLES;
|
|
@ -1,37 +0,0 @@
|
|||
# Header section
|
||||
# Define incrementing schema version number
|
||||
SET @schema_version = '27';
|
||||
|
||||
# Create table to report templates
|
||||
CREATE TABLE `report_templates` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(255) DEFAULT '',
|
||||
`mime_type` varchar(255) DEFAULT 'text/html' NOT NULL,
|
||||
`description` text,
|
||||
`user_fields` longtext,
|
||||
`js` longtext,
|
||||
`hbs` longtext,
|
||||
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
# Create table to store reports
|
||||
CREATE TABLE `reports` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(255) DEFAULT '',
|
||||
`description` text,
|
||||
`report_template` int(11) unsigned NOT NULL,
|
||||
`params` longtext,
|
||||
`state` int(11) unsigned NOT NULL DEFAULT 0,
|
||||
`last_run` DATETIME DEFAULT NULL,
|
||||
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `report_template` (`report_template`),
|
||||
CONSTRAINT `report_template_ibfk_1` FOREIGN KEY (`report_template`) REFERENCES `report_templates` (`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
|
||||
# Footer section
|
||||
LOCK TABLES `settings` WRITE;
|
||||
INSERT INTO `settings` (`key`, `value`) VALUES('db_schema_version', @schema_version) ON DUPLICATE KEY UPDATE `value`=@schema_version;
|
||||
UNLOCK TABLES;
|
|
@ -1,33 +0,0 @@
|
|||
# Header section
|
||||
# Define incrementing schema version number
|
||||
SET @schema_version = '28';
|
||||
|
||||
# Add unsubscription mode field to lists
|
||||
ALTER TABLE `lists` ADD COLUMN `unsubscription_mode` int(11) unsigned DEFAULT 0 NOT NULL AFTER `public_subscribe`;
|
||||
|
||||
# Delete all confirmations as we use different structure in "data".
|
||||
DELETE FROM `confirmations`;
|
||||
|
||||
# Change the name of the column to better reflect that confirmations are also used for unsubscription and email address update
|
||||
# Drop email field as this does not have a clear semantics in change address. Since email is not used to search in the table,
|
||||
# it can be stored in data
|
||||
# Create field action to distinguish between different confirmation types (subscribe, unsubscribe, change-address)
|
||||
ALTER TABLE `confirmations` CHANGE `opt_in_ip` `ip` varchar(100) DEFAULT NULL;
|
||||
ALTER TABLE `confirmations` DROP `email`;
|
||||
ALTER TABLE `confirmations` ADD COLUMN `action` varchar(100) NOT NULL AFTER `list`;
|
||||
|
||||
|
||||
# Rename affected forms in custom_forms_data
|
||||
update custom_forms_data set data_key="mail_confirm_subscription_html" where data_key="mail_confirm_html";
|
||||
update custom_forms_data set data_key="mail_confirm_subscription_text" where data_key="mail_confirm_text";
|
||||
update custom_forms_data set data_key="mail_unsubscription_confirmed_html" where data_key="mail_unsubscribe_confirmed_html";
|
||||
update custom_forms_data set data_key="mail_unsubscription_confirmed_text" where data_key="mail_unsubscribe_confirmed_text";
|
||||
update custom_forms_data set data_key="web_confirm_subscription_notice" where data_key="web_confirm_notice";
|
||||
update custom_forms_data set data_key="web_subscribed_notice" where data_key="web_subscribed";
|
||||
update custom_forms_data set data_key="web_unsubscribed_notice" where data_key="web_unsubscribe_notice";
|
||||
|
||||
|
||||
# Footer section
|
||||
LOCK TABLES `settings` WRITE;
|
||||
INSERT INTO `settings` (`key`, `value`) VALUES('db_schema_version', @schema_version) ON DUPLICATE KEY UPDATE `value`=@schema_version;
|
||||
UNLOCK TABLES;
|
|
@ -1,13 +0,0 @@
|
|||
# Header section
|
||||
# Define incrementing schema version number
|
||||
SET @schema_version = '29';
|
||||
|
||||
# Rename column tracking_disabled
|
||||
ALTER TABLE `campaigns` ADD COLUMN `open_tracking_disabled` tinyint(4) unsigned DEFAULT 0 NOT NULL, ADD COLUMN `click_tracking_disabled` tinyint(4) unsigned DEFAULT 0 NOT NULL;
|
||||
UPDATE `campaigns` SET `open_tracking_disabled` = `tracking_disabled`, `click_tracking_disabled` = `tracking_disabled`;
|
||||
ALTER TABLE `campaigns` DROP COLUMN `tracking_disabled`;
|
||||
|
||||
# Footer section
|
||||
LOCK TABLES `settings` WRITE;
|
||||
INSERT INTO `settings` (`key`, `value`) VALUES('db_schema_version', @schema_version) ON DUPLICATE KEY UPDATE `value`=@schema_version;
|
||||
UNLOCK TABLES;
|
|
@ -1,17 +0,0 @@
|
|||
# Header section
|
||||
# Define incrementing schema version number
|
||||
SET @schema_version = '30';
|
||||
|
||||
# Upgrade script section
|
||||
#### INSERT YOUR UPGRADE SCRIPT BELOW THIS LINE ######
|
||||
|
||||
ALTER TABLE `lists` ADD COLUMN `listunsubscribe_disabled` tinyint(4) unsigned DEFAULT 0 NOT NULL;
|
||||
|
||||
#### INSERT YOUR UPGRADE SCRIPT ABOVE THIS LINE ######
|
||||
|
||||
# Footer section. Updates schema version in settings
|
||||
LOCK TABLES `settings` WRITE;
|
||||
/*!40000 ALTER TABLE `settings` DISABLE KEYS */;
|
||||
INSERT INTO `settings` (`key`, `value`) VALUES('db_schema_version', @schema_version) ON DUPLICATE KEY UPDATE `value`=@schema_version;
|
||||
/*!40000 ALTER TABLE `settings` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
|
@ -1,12 +0,0 @@
|
|||
# Header section
|
||||
# Define incrementing schema version number
|
||||
SET @schema_version = '31';
|
||||
|
||||
# Add segment support for triggers
|
||||
ALTER TABLE `triggers` ADD `segment` INT(11) UNSIGNED NOT NULL AFTER `list`;
|
||||
ALTER TABLE `trigger` ADD `segment` INT(11) UNSIGNED NOT NULL AFTER `list`;
|
||||
|
||||
# Footer section
|
||||
LOCK TABLES `settings` WRITE;
|
||||
INSERT INTO `settings` (`key`, `value`) VALUES('db_schema_version', @schema_version) ON DUPLICATE KEY UPDATE `value`=@schema_version;
|
||||
UNLOCK TABLES;
|
|
@ -1,15 +0,0 @@
|
|||
# Header section
|
||||
# Define incrementing schema version number
|
||||
SET @schema_version = '32';
|
||||
|
||||
# Set default X-Mailer header value
|
||||
LOCK TABLES `settings` WRITE;
|
||||
INSERT INTO `settings` (`key`, `value`) VALUES ('x_mailer','Mailtrain Mailer (+https://mailtrain.org)') ON DUPLICATE KEY UPDATE `value`='Mailtrain Mailer (+https://mailtrain.org)';
|
||||
UNLOCK TABLES;
|
||||
|
||||
# Footer section. Updates schema version in settings
|
||||
LOCK TABLES `settings` WRITE;
|
||||
/*!40000 ALTER TABLE `settings` DISABLE KEYS */;
|
||||
INSERT INTO `settings` (`key`, `value`) VALUES('db_schema_version', @schema_version) ON DUPLICATE KEY UPDATE `value`=@schema_version;
|
||||
/*!40000 ALTER TABLE `settings` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
|
@ -1,13 +0,0 @@
|
|||
# Header section
|
||||
# Define incrementing schema version number
|
||||
SET @schema_version = '33';
|
||||
|
||||
# Adds new column 'unsubscribe' to campaign table.
|
||||
ALTER TABLE campaigns ADD COLUMN `unsubscribe` VARCHAR(255) NOT NULL DEFAULT '' AFTER `subject`;
|
||||
|
||||
# Footer section. Updates schema version in settings
|
||||
LOCK TABLES `settings` WRITE;
|
||||
/*!40000 ALTER TABLE `settings` DISABLE KEYS */;
|
||||
INSERT INTO `settings` (`key`, `value`) VALUES('db_schema_version', @schema_version) ON DUPLICATE KEY UPDATE `value`=@schema_version;
|
||||
/*!40000 ALTER TABLE `settings` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
|
@ -1,21 +0,0 @@
|
|||
# This file is a handlebars template
|
||||
# To modify several similar tables at once use (replace [] with {}):
|
||||
# [[#each tables.tablename]] ALTER TABLE `[[this]]` ... [[/each]]
|
||||
# NB! as this is a handlebars file, then remember to escape any template sequences
|
||||
|
||||
# Header section
|
||||
# Define incrementing schema version number
|
||||
SET @schema_version = 'XXX';
|
||||
|
||||
# Upgrade script section
|
||||
#### INSERT YOUR UPGRADE SCRIPT BELOW THIS LINE ######
|
||||
|
||||
|
||||
#### INSERT YOUR UPGRADE SCRIPT ABOVE THIS LINE ######
|
||||
|
||||
# Footer section. Updates schema version in settings
|
||||
LOCK TABLES `settings` WRITE;
|
||||
/*!40000 ALTER TABLE `settings` DISABLE KEYS */;
|
||||
INSERT INTO `settings` (`key`, `value`) VALUES('db_schema_version', @schema_version) ON DUPLICATE KEY UPDATE `value`=@schema_version;
|
||||
/*!40000 ALTER TABLE `settings` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
Loading…
Add table
Add a link
Reference in a new issue