Commit d219d421 authored by Michał 'rysiek' Woźniak's avatar Michał 'rysiek' Woźniak
Browse files

checking database schema version before setting it up, so that a valid db doesn't get overwritten!

parent 6f94dfb7
...@@ -227,9 +227,16 @@ echo "+-- creating and setting permissions on the tmp directory '$WEBSCHLOCKER_T ...@@ -227,9 +227,16 @@ echo "+-- creating and setting permissions on the tmp directory '$WEBSCHLOCKER_T
mkdir -p "$WEBSCHLOCKER_TMP_DIR" mkdir -p "$WEBSCHLOCKER_TMP_DIR"
chown -R "$WEBSCHLOCKER_USER:$WEBSCHLOCKER_GROUP" "$WEBSCHLOCKER_TMP_DIR" chown -R "$WEBSCHLOCKER_USER:$WEBSCHLOCKER_GROUP" "$WEBSCHLOCKER_TMP_DIR"
# prep the database (as the correct user) # which version of the db we have?
echo "+-- setting up the database" echo "+-- checking db schema version..."
su -p -c "env PATH=\"$PATH\" bundle exec rake db:setup RAILS_ENV=production" "$WEBSCHLOCKER_USER" WEBSCHLEUDER_SCHEMA_VERSION="$( su -p -c "env PATH=\"$PATH\" bundle exec rake db:version RAILS_ENV=production" "$WEBSCHLOCKER_USER" | awk '/^Current version:/ {print $3}' )"
if [[ $WEBSCHLEUDER_SCHEMA_VERSION > 0 ]]; then
echo " +-- database schema version found: $WEBSCHLEUDER_SCHEMA_VERSION, no need for set-up"
else
# prep the database (as the correct user)
echo " +-- database schema not found, setting up the database"
su -p -c "env PATH=\"$PATH\" bundle exec rake db:setup RAILS_ENV=production" "$WEBSCHLOCKER_USER"
fi
# make sure the envvars are available within su # make sure the envvars are available within su
export WEBSCHLOCKER_BIND_ADDRESS WEBSCHLOCKER_BIND_PORT export WEBSCHLOCKER_BIND_ADDRESS WEBSCHLOCKER_BIND_PORT
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment