#!/bin/sh

# This is a compatible rewrite of https://github.com/sahana/eden_deploy/blob/master/roles/common/files/migrate specific for Alpine s6-based container

# Migrate database
cd /srv/web2py
sed -i 's/settings.base.migrate = False/settings.base.migrate = True/g' applications/eden/models/000_config.py
rm -rf applications/eden/compiled
sudo -u sahana -- ./web2py.py -S eden -M -R applications/eden/static/scripts/tools/noop.py
sed -i 's/settings.base.migrate = True/settings.base.migrate = False/g' applications/eden/models/000_config.py

# Restart uwsgi
s6-svc -t /etc/services.d/uwsgi
