From 0a38c1f40d8804076782efe249234b9850d1c7af Mon Sep 17 00:00:00 2001 From: fumimowdan Date: Wed, 13 Sep 2023 17:04:25 +0100 Subject: [PATCH] Disable troublesome migration Run rails db:seed in review environment when app starts Updated Dockerfile to use a app startup shell script for that effect --- Dockerfile | 3 +-- bin/app-startup.sh | 16 ++++++++++++++++ .../20230721082851_enable_opening_times.rb | 5 +---- 3 files changed, 18 insertions(+), 6 deletions(-) create mode 100755 bin/app-startup.sh diff --git a/Dockerfile b/Dockerfile index 3a32fedb..39153c29 100644 --- a/Dockerfile +++ b/Dockerfile @@ -44,5 +44,4 @@ ENV GOVUK_NOTIFY_GENERIC_EMAIL_TEMPLATE_ID=$GOVUK_NOTIFY_GENERIC_EMAIL_TEMPLATE_ RUN bundle exec rake assets:precompile && \ rm -rf node_modules tmp -CMD bundle exec rails db:migrate && \ - bundle exec rails server -b 0.0.0.0 +CMD ./bin/app-startup.sh \ No newline at end of file diff --git a/bin/app-startup.sh b/bin/app-startup.sh new file mode 100755 index 00000000..e28122a7 --- /dev/null +++ b/bin/app-startup.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env sh +# +# Dockerfile application startup script +# + +# run migrations +bundle exec rails db:migrate + +# add seed data in review environment +if [ "$RAILS_ENV" = "review" ]; then + echo "Running rails db:seed" + bundle exec rails db:seed +fi + +# start server +bundle exec rails server -b 0.0.0.0 diff --git a/db/migrate/20230721082851_enable_opening_times.rb b/db/migrate/20230721082851_enable_opening_times.rb index d86d932a..0e9b4190 100644 --- a/db/migrate/20230721082851_enable_opening_times.rb +++ b/db/migrate/20230721082851_enable_opening_times.rb @@ -1,8 +1,5 @@ class EnableOpeningTimes < ActiveRecord::Migration[7.0] def change - AppSettings.current.update!( - service_start_date: Time.zone.yesterday, - service_end_date: Time.zone.today + 1.year, - ) + # Disable this migration and move code into task `rake set_app_settings` end end