Skip to content

Commit

Permalink
Run migrations in fabfile
Browse files Browse the repository at this point in the history
  • Loading branch information
dhamaniasad committed Dec 2, 2017
1 parent 0cb6797 commit 95b22a9
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions fabfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def vagrant_init():
execute(create_database)
execute(config_environment)
execute(setup_crestify_config)
execute(run_migrations)
execute(setup_nginx)
execute(setup_supervisor)

Expand Down Expand Up @@ -97,6 +98,13 @@ def config_environment():
sudo('pip install -r crestify/requirements.txt')


def run_migrations():
with settings(sudo_user='crestify', shell='/bin/bash -c'):
with cd('/home/crestify/crestify'):
with prefix('source ../crestifyenv/bin/activate'):
sudo('honcho run python main.py db upgrade') # Run initial migrations


def setup_crestify_config():
with settings(sudo_user="crestify", shell='/bin/bash -c'):
with cd('/home/crestify'):
Expand Down Expand Up @@ -145,12 +153,14 @@ def update():
def _git_update():
with settings(sudo_user="crestify", shell='/bin/bash -c'):
with cd('/home/crestify/crestify'):
sudo('git pull')
with cd('/home/crestify'):
with settings(sudo_user='crestify', shell='/bin/bash -c'):
with prefix('source crestifyenv/bin/activate'):
sudo('pip install -r crestify/requirements.txt')
with prefix('source ../crestifyenv/bin/activate'):
with settings(sudo_user='crestify', shell='/bin/bash -c'):
sudo('git pull')
sudo('pip install -r requirements.txt')
sudo('honcho run python main.py db upgrade')


def _restart_supervisor():
sudo('supervisorctl reread all')
sudo('supervisorctl update all')
sudo('supervisorctl restart all')

0 comments on commit 95b22a9

Please sign in to comment.