Skip to content

Commit

Permalink
Update migration subject scripts and initial gochan db version
Browse files Browse the repository at this point in the history
  • Loading branch information
Eggbertx committed Sep 22, 2024
1 parent 5761662 commit a92b120
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 20 deletions.
2 changes: 1 addition & 1 deletion sql/initdb_master.sql
Original file line number Diff line number Diff line change
Expand Up @@ -294,4 +294,4 @@ CREATE TABLE DBPREFIXfilter_hits(


INSERT INTO DBPREFIXdatabase_version(component, version)
VALUES('gochan', 3);
VALUES('gochan', 4);
2 changes: 1 addition & 1 deletion sql/initdb_mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -294,4 +294,4 @@ CREATE TABLE DBPREFIXfilter_hits(


INSERT INTO DBPREFIXdatabase_version(component, version)
VALUES('gochan', 3);
VALUES('gochan', 4);
2 changes: 1 addition & 1 deletion sql/initdb_postgres.sql
Original file line number Diff line number Diff line change
Expand Up @@ -294,4 +294,4 @@ CREATE TABLE DBPREFIXfilter_hits(


INSERT INTO DBPREFIXdatabase_version(component, version)
VALUES('gochan', 3);
VALUES('gochan', 4);
2 changes: 1 addition & 1 deletion sql/initdb_sqlite3.sql
Original file line number Diff line number Diff line change
Expand Up @@ -294,4 +294,4 @@ CREATE TABLE DBPREFIXfilter_hits(


INSERT INTO DBPREFIXdatabase_version(component, version)
VALUES('gochan', 3);
VALUES('gochan', 4);
2 changes: 1 addition & 1 deletion tools/get_pre2021.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ if [ "$DBTYPE" = "mysql" ]; then
EOF1
elif [ "$DBTYPE" = "postgresql" ]; then
echo "Creating pre-2021 PostgreSQL DB 'gochan_pre2021' if it doesn't already exist"
sed -i /etc/gochan/gochan.json \
sed -i gochan.json \
-e 's/"DBhost": ".*"/"DBhost": "127.0.0.1"/'
sudo -u postgres psql -f - <<- EOF1
CREATE DATABASE gochan_pre2021;
Expand Down
32 changes: 17 additions & 15 deletions tools/get_previous_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

set -euo pipefail

TESTING_VERSION="v3.7.0"
TESTING_VERSION="v3.10.2"
RELEASE_DIR="gochan-${TESTING_VERSION}_linux"
RELEASE_GZ="$RELEASE_DIR.tar.gz"
RELEASE_URL="https://github.com/gochan-org/gochan/releases/download/$TESTING_VERSION/$RELEASE_GZ"
Expand All @@ -23,39 +23,41 @@ echo "Extracting $RELEASE_GZ"
tar -xf gochan-${TESTING_VERSION}_linux.tar.gz
cd $RELEASE_DIR

cp sample-configs/gochan.example.json gochan.json
cp examples/configs/gochan.example.json gochan.json
echo "Modifying $PWD/gochan.json for testing migration"
sed -i gochan.json \
-e 's/"Port": .*/"Port": 9000,/' \
-e 's/"UseFastCGI": false/"UseFastCGI": true/' \
-e "s/\"DBtype\": .*/\"DBtype\": \""$DBTYPE"\",/" \
-e 's/"DBpassword": ""/"DBpassword": "gochan"/' \
-e 's/"LogDir": .*/"LogDir": "log"/' \
-e 's/"TemplateDir": .*/"TemplateDir": "templates"/' \
-e 's/"DocumentRoot": .*/"DocumentRoot": "html"/' \
-e 's/"DBname": "gochan"/"DBname": "gochan_37"/' \
-e 's/"DBprefix": .*/"DBprefix": ""/' \
-e 's/"LogDir": .*/"LogDir": "log",/' \
-e 's/"TemplateDir": .*/"TemplateDir": "templates",/' \
-e 's/"DocumentRoot": .*/"DocumentRoot": "html",/' \
-e 's/"DBname": "gochan"/"DBname": "gochan_prev"/' \
-e 's/"DBprefix": .*/"DBprefix": "",/' \
-e 's/"SiteName": "Gochan"/"SiteName": "Gochan Migration Test"/' \
-e 's/"SiteSlogan": ""/"SiteSlogan": "Gochan instance used for testing gochan-migrate -updatedb"/' \
-e 's/"DebugMode": false/"DebugMode": true/' \
-e 's/"Verbosity": 0/"Verbosity": 1/'
-e 's/"Verbosity": 0/"Verbosity": 1/' \
-e 's/"GeoIPType": .*/"GeoIPType": "",/'
-e 's/"EnableGeoIP": .*/"EnableGeoIP": false,/'

if [ "$DBTYPE" = "mysql" ]; then
echo "Creating testing MySQL DB 'gochan_37' if it doesn't already exist"
echo "Creating testing MySQL DB 'gochan_prev' if it doesn't already exist"
sudo mysql <<- EOF1
CREATE DATABASE IF NOT EXISTS gochan_37;
CREATE DATABASE IF NOT EXISTS gochan_prev;
GRANT USAGE ON *.* TO gochan IDENTIFIED BY 'gochan'; \
GRANT ALL PRIVILEGES ON gochan_37.* TO gochan; \
GRANT ALL PRIVILEGES ON gochan_prev.* TO gochan; \
SET PASSWORD FOR 'gochan'@'%' = PASSWORD('gochan');
FLUSH PRIVILEGES;
EOF1
elif [ "$DBTYPE" = "postgresql" ]; then
echo "Creating testing PostgreSQL DB 'gochan_37' if it doesn't already exist"
sed -i /etc/gochan/gochan.json \
echo "Creating testing PostgreSQL DB 'gochan_prev' if it doesn't already exist"
sed -i gochan.json \
-e 's/"DBhost": ".*"/"DBhost": "127.0.0.1"/'
sudo -u postgres psql -f - <<- EOF1
CREATE DATABASE gochan_37;
GRANT ALL PRIVILEGES ON DATABASE gochan_37 TO gochan;
CREATE DATABASE gochan_prev;
GRANT ALL PRIVILEGES ON DATABASE gochan_prev TO gochan;
EOF1
else
echo "Currently using unsupported \$DBTYPE: $DBTYPE"
Expand Down

0 comments on commit a92b120

Please sign in to comment.