-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run code in a task instead avoid incompatibility with future code changes
- Loading branch information
1 parent
723149f
commit 2517e75
Showing
4 changed files
with
35 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
desc "sets app setting for environments different than production with no setting" | ||
task set_app_settings: :environment do | ||
if Rails.env.production? | ||
msg = "Not changing production settings" | ||
puts msg | ||
Rails.logger.info(msg) | ||
exit | ||
end | ||
|
||
current_setting = AppSettings.current | ||
if current_setting.configured? | ||
msg = "Keeping existing setting: #{current_setting}" | ||
puts msg | ||
Rails.logger.info(msg) | ||
exit | ||
end | ||
|
||
current_setting.update!( | ||
service_start_date: Time.zone.yesterday, | ||
service_end_date: Time.zone.today + 1.year, | ||
) | ||
msg = "Updated settings to: #{current_setting}" | ||
puts msg | ||
Rails.logger.info(msg) | ||
end |