-
Notifications
You must be signed in to change notification settings - Fork 495
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make auto db creation optional with DB_CREATE #558
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -1048,8 +1048,27 @@ migrate_database() { | |||||||||||||||||||||
CACHE_VERSION= | ||||||||||||||||||||||
[[ -f ${REDMINE_DATA_DIR}/tmp/VERSION ]] && CACHE_VERSION=$(cat ${REDMINE_DATA_DIR}/tmp/VERSION) | ||||||||||||||||||||||
if [[ ${REDMINE_VERSION} != ${CACHE_VERSION} ]]; then | ||||||||||||||||||||||
if [[ "${DB_CREATE:-true}" == "true" ]] ; then | ||||||||||||||||||||||
echo "Creating database..." | ||||||||||||||||||||||
# Disable "exit on error" so we can capture the error code | ||||||||||||||||||||||
set +e | ||||||||||||||||||||||
exec_as_redmine bundle exec rake db:create >/dev/null | ||||||||||||||||||||||
res=$? | ||||||||||||||||||||||
# Restore "exit on error" | ||||||||||||||||||||||
set -e | ||||||||||||||||||||||
|
||||||||||||||||||||||
if [[ 0 -ne $res ]] ; then | ||||||||||||||||||||||
Comment on lines
+1053
to
+1060
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note shellcheck will tell you its better to if check the command directly instead of storing the results. I think this also would mean we don't have to disable exit on error.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I wanted to retain the exit value from I'm happy to change it you are ok with returning a fixed value, e.g.:
|
||||||||||||||||||||||
echo <<-EOM | ||||||||||||||||||||||
Failed to create db. If db exists, and user (or role) exists and has access to db but no permission to create databases, set: | ||||||||||||||||||||||
----------------------- | ||||||||||||||||||||||
DB_CREATE=false | ||||||||||||||||||||||
----------------------- | ||||||||||||||||||||||
EOM | ||||||||||||||||||||||
return $res | ||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be an exit if we are to keep the previous behavior. As is, this will skip db migration and then redmine will continue to try to start, likely leading to more confusing errors. |
||||||||||||||||||||||
fi | ||||||||||||||||||||||
fi | ||||||||||||||||||||||
|
||||||||||||||||||||||
echo "Migrating database. Please be patient, this could take a while..." | ||||||||||||||||||||||
exec_as_redmine bundle exec rake db:create >/dev/null | ||||||||||||||||||||||
exec_as_redmine bundle exec rake db:migrate >/dev/null | ||||||||||||||||||||||
|
||||||||||||||||||||||
# clear sessions and application cache | ||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
defaults should all be set in assets/runtime/env-defaults for consistency