1
0
Fork 0
mirror of https://github.com/Eggbertx/gochan.git synced 2025-08-24 08:46:24 -07:00

Fix alter table SQL statement in sqlite3 block

Also, add environment variable for installing mainline MySQL (instead of MariaDB) in vagrant
This commit is contained in:
Eggbertx 2023-03-27 19:51:34 -07:00
parent 353b5d7552
commit 881a87c6b1
3 changed files with 23 additions and 4 deletions

View file

@ -120,7 +120,14 @@ func tmpSqlAdjust() error {
if err != nil {
return err
}
_, err = ExecSQL(`ALTER TABLE DBPREFIXwordfilters ADD COLUMN IF NOT EXISTS board_dirs varchar(255) DEFAULT '*'`)
query = `SELECT COUNT(*) FROM PRAGMA_TABLE_INFO('DBPREFIXwordfilters') WHERE name = 'board_dirs'`
var numColumns int
if err = QueryRowSQL(query, interfaceSlice(), interfaceSlice(&numColumns)); err != nil {
return err
}
if numColumns == 0 {
_, err = ExecSQL(`ALTER TABLE DBPREFIXwordfilters ADD COLUMN board_dirs varchar(255) DEFAULT '*'`)
}
}
return err

1
vagrant/Vagrantfile vendored
View file

@ -31,6 +31,7 @@ Vagrant.configure("2") do |config|
config.vm.provision :shell, path: "bootstrap.sh", env: {
:DBTYPE => DBTYPE,
:GOPATH => "/home/vagrant/go",
:MYSQL_MAINLINE => ENV.fetch("GC_MYSQL_MAINLINE", ""),
:FROMDOCKER => ""
}, args: "install"
end

View file

@ -17,7 +17,13 @@ apt-get -y update && apt-get -y upgrade
if [ "$DBTYPE" == "mysql" ]; then
# Using MySQL (stable)
apt-get -y install mariadb-server mariadb-client
if [ "$MYSQL_MAINLINE" == "1" ]; then
echo "using mainline MySQL instead of MariaDB"
apt-get -y install mysql-server mysql-client
else
echo "using MariaDB fork of MySQL (default)"
apt-get -y install mariadb-server mariadb-client
fi
mysql -uroot <<- EOF
CREATE DATABASE IF NOT EXISTS gochan;
GRANT USAGE ON *.* TO gochan IDENTIFIED BY 'gochan'; \
@ -25,8 +31,13 @@ if [ "$DBTYPE" == "mysql" ]; then
SET PASSWORD FOR 'gochan'@'%' = PASSWORD('gochan');
FLUSH PRIVILEGES;
EOF
systemctl enable mariadb
systemctl start mariadb &
if [ "$MYSQL_MAINLINE" == "1" ]; then
systemctl enable mysql
systemctl start mysql &
else
systemctl enable mariadb
systemctl start mariadb &
fi
wait
if [ -d /lib/systemd ]; then
cp /vagrant/sample-configs/gochan-mysql.service /lib/systemd/system/gochan.service