-
Notifications
You must be signed in to change notification settings - Fork 342
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Some changes require manual action, like those affecting what is run only during installation. It'd be nice if we had something for that similar to what flyway does for the DB changes.
- Loading branch information
1 parent
05ee06a
commit a5fbfff
Showing
5 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
checkpoint |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Migration scripts | ||
----------------- | ||
|
||
When changes in Freeciv-web may make current installations stop working, a | ||
migration script should be provided to help users find and understand the | ||
changeset, and hopefully migrate their installation with no issues if it's | ||
a default setup. | ||
|
||
The filenames start with a sequential four-digit number. When `migrate.sh` | ||
is executed it runs each of them in order, following from where it stopped | ||
in its last execution. | ||
|
||
The scripts may still fail on purpose if manual action is required (or safer | ||
than trying to script it). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/bin/bash | ||
|
||
# Copyright (C) 2018 The Freeciv-web project | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Affero General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
# Runs new migration scripts. | ||
# migrate.sh [migration_dir] | ||
# | ||
# Every file in migration_dir starting with a number is run in lexicographical | ||
# order, except the ones lower than or equal to the saved checkpoint. | ||
|
||
set -e | ||
|
||
if [ -z "$1" ]; then | ||
BASEDIR=${BASH_SOURCE%/*} | ||
else | ||
BASEDIR=$1 | ||
fi | ||
|
||
if [ -z "${BASEDIR}" ]; then | ||
echo >&2 "Please pass the directory with the migration scripts" | ||
exit 1 | ||
fi | ||
|
||
if [ "${BASEDIR:0:1}" = - ]; then | ||
BASEDIR=./"${BASEDIR}" | ||
fi | ||
|
||
cd "${BASEDIR}" | ||
|
||
if [ -f checkpoint ]; then | ||
read LAST < checkpoint | ||
fi | ||
|
||
for f in [0-9]*; do | ||
if [ "$f" \> "${LAST}" ]; then | ||
echo "Running $f" | ||
./"$f" | ||
echo "$f" > checkpoint | ||
fi | ||
done | ||
|
||
echo "Migration finished" |