---

- name: Delete old database with same name if it exists
  shell: echo "DROP DATABASE IF EXISTS {{mysql_db_name}}" | mysql -u {{mysql_user}} -p{{mysql_password}}
- name: Create a new mysql database
  shell: echo "CREATE DATABASE {{mysql_db_name}}" | mysql -u {{mysql_user}} -p{{mysql_password}}
- name: Initialize database schema
  shell: find {{code_dir}}/docs/database/tables -type f -exec cat {} \; | mysql -u {{mysql_user}} -p{{mysql_password}} {{mysql_db_name}}
- name: Fill database with initial values
  shell: mysql -u {{mysql_user}} -p{{mysql_root_password}} {{mysql_db_name}} < {{code_dir}}/docs/database/{{item}}
  with_items:
  - import/users.sql
  - import/acos.sql
  - import/aros_acos.sql
  - import/aros.sql
  - import/countries.sql
  - import/groups.sql
  - import/sinograms.sql
  - import/sinogram_subglyphs.sql
- name: Install database triggers
# This task requires mysql root for creating triggers
  shell: find {{code_dir}}/docs/database/triggers -type f -exec cat {} \; | mysql -u root -p{{mysql_root_password}} {{mysql_db_name}}

---

- name: Delete old database with same name if it exists
  shell: echo "DROP DATABASE IF EXISTS {{mysql_db_name}}" | mysql -u {{mysql_user}} -p{{mysql_password}}
- name: Create a new mysql database
  shell: echo "CREATE DATABASE {{mysql_db_name}}" | mysql -u {{mysql_user}} -p{{mysql_password}}
- name: Initialize database schema
  shell: find {{code_dir}}/docs/database/tables -type f -exec cat {} \; | mysql -u {{mysql_user}} -p{{mysql_password}} {{mysql_db_name}}
- name: Fill database with initial values
  shell: mysql -u {{mysql_user}} -p{{mysql_root_password}} {{mysql_db_name}} < {{code_dir}}/docs/database/{{item}}
  with_items:
  - import/users.sql
  - import/acos.sql
  - import/aros_acos.sql
  - import/aros.sql
  - import/groups.sql
  - import/sinograms.sql
  - import/sinogram_subglyphs.sql
- name: Install database triggers
# This task requires mysql root for creating triggers
  shell: find {{code_dir}}/docs/database/triggers -type f -exec cat {} \; | mysql -u root -p{{mysql_root_password}} {{mysql_db_name}}

Remove reference to SQL file that no longer exists
Remove reference to SQL file that no longer exists
