Skip to content

Commit

Permalink
setup - added django db schema update script
Browse files Browse the repository at this point in the history
  • Loading branch information
superstes committed Jul 6, 2021
1 parent e1bdd7b commit 1bf302d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
9 changes: 6 additions & 3 deletions setup/roles/web/tasks/django.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,17 @@
state: present
notify: 'restart_apache'

- name: GA | Web | Django | Adding database config
- name: GA | Web | Django | Adding database config and update script
template:
src: "templates/var/www/ga/database.cnf.j2"
dest: "{{ ga_web_path }}/database.cnf"
src: "templates/var/www/ga/{{ item }}.j2"
dest: "{{ ga_web_path }}/{{ item }}"
owner: "{{ ga_web_service_user }}"
group: "{{ ga_service_group }}"
mode: 0440
notify: 'restart_apache'
with_items:
- 'database.cnf'
- 'update_schema.sh'

- name: GA | Web | Django | Configuring django settings
lineinfile:
Expand Down
13 changes: 13 additions & 0 deletions setup/roles/web/templates/var/www/ga/update_schema.sh.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
# django db schema update script

WEB_PATH='{{ ga_web_path }}'
VENV_PATH='{{ ga_web_path_venv }}'
CORE_PATH='{{ ga_core_path }}'

export DJANGO_SETTINGS_MODULE=base.settings
export PYTHONPATH=${WEB_PATH}:${CORE_PATH}:${VENV_PATH}/lib/python{{ ga_python_version }}/site-packages

cd ${WEB_PATH}
source ${VENV_BIN_PATH}/activate
${VENV_BIN_PATH}/bin/python3 manage.py makemigrations && ${VENV_BIN_PATH}/bin/python3 manage.py migrate && sudo systemctl restart apache2.service

0 comments on commit 1bf302d

Please sign in to comment.