From b053c8cb81b77f25f8ee22e9a1f1468176fce345 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sun, 20 Aug 2023 18:55:49 +0100 Subject: [PATCH] Simplify database preparation task --- roles/deploy/tasks/deploy.yml | 7 ++++++- roles/deploy/tasks/prepare_database.yml | 28 ------------------------- 2 files changed, 6 insertions(+), 29 deletions(-) delete mode 100644 roles/deploy/tasks/prepare_database.yml diff --git a/roles/deploy/tasks/deploy.yml b/roles/deploy/tasks/deploy.yml index 6d3c0b468..c1968d6c7 100644 --- a/roles/deploy/tasks/deploy.yml +++ b/roles/deploy/tasks/deploy.yml @@ -115,8 +115,13 @@ tags: rake - name: prepare database for the first time - include_tasks: prepare_database.yml + command: bash -lc "bundle exec rails db:setup RAILS_ENV={{ rails_env }} I_AM_SURE=1" + args: + chdir: "{{ build_path }}" when: table_exists.stdout.find('0 rows') != -1 + tags: + - rake + - skip_ansible_lint - name: clear transient data command: bash -lc "bundle exec rake ofn:data:remove_transient_data RAILS_ENV={{ rails_env }}" diff --git a/roles/deploy/tasks/prepare_database.yml b/roles/deploy/tasks/prepare_database.yml deleted file mode 100644 index 0e7144943..000000000 --- a/roles/deploy/tasks/prepare_database.yml +++ /dev/null @@ -1,28 +0,0 @@ ---- -# Ensure the database is created, migrated and seeded (first deployment only) - -- name: load database schema - command: bash -lc "bundle exec rake db:schema:load RAILS_ENV={{ rails_env }} I_AM_SURE=1" - args: - chdir: "{{ build_path }}" - tags: - - rake - - skip_ansible_lint - -- name: migrate database - command: bash -lc "bundle exec rake db:migrate RAILS_ENV={{ rails_env }}" - args: - chdir: "{{ build_path }}" - tags: - - rake - - skip_ansible_lint - notify: restart puma - -- name: seed database - command: bash -lc "bundle exec rake db:seed RAILS_ENV={{ rails_env }}" - args: - chdir: "{{ build_path }}" - tags: - - seed - - skip_ansible_lint - notify: restart puma