Remove tasks to upgrade to version 1.1
These tasks are not needed for new installations, and in existing installations they've already been executed when upgrading to version 1.1. One of them also raises a warning in Rails 5.2: DEPRECATION WARNING: Dangerous query method (method whose arguments are used as raw SQL) called with non-attribute argument(s): "MIN(id) as id". Non-attribute arguments will be disallowed in Rails 6.0. This method should not be called with user-provided values, such as request parameters or model attributes. Known-safe values can be passed by wrapping them in Arel.sql()
This commit is contained in:
@@ -10,15 +10,4 @@ namespace :budgets do
|
||||
Budget.last.email_unselected
|
||||
end
|
||||
end
|
||||
|
||||
desc "Update investments original_heading_id with current heading_id"
|
||||
task set_original_heading_id: :environment do
|
||||
ApplicationLogger.new.info "Setting original_heading_id to investments"
|
||||
Budget::Investment.find_each do |investment|
|
||||
unless investment.original_heading_id.present?
|
||||
investment.update_column(:original_heading_id, investment.heading_id)
|
||||
end
|
||||
print "."
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,13 +1,5 @@
|
||||
namespace :consul do
|
||||
desc "Runs tasks needed to upgrade to the latest version"
|
||||
task execute_release_tasks: ["settings:rename_setting_keys",
|
||||
"settings:add_new_settings",
|
||||
"execute_release_1.1.0_tasks"]
|
||||
|
||||
desc "Runs tasks needed to upgrade from 1.0.0 to 1.1.0"
|
||||
task "execute_release_1.1.0_tasks": [
|
||||
"budgets:set_original_heading_id",
|
||||
"migrations:valuation_taggings",
|
||||
"migrations:budget_admins_and_valuators"
|
||||
]
|
||||
"settings:add_new_settings"]
|
||||
end
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
namespace :local_census_records do
|
||||
desc "Remove duplicated records from database"
|
||||
task remove_duplicates: :environment do
|
||||
ids = LocalCensusRecord.group(:document_type, :document_number).pluck("MIN(id) as id")
|
||||
duplicates = LocalCensusRecord.count - ids.size
|
||||
|
||||
if duplicates > 0
|
||||
ApplicationLogger.new.info "Removing local census records duplicates"
|
||||
LocalCensusRecord.where("id NOT IN (?)", ids).destroy_all
|
||||
ApplicationLogger.new.info "Removed #{duplicates} records."
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,20 +0,0 @@
|
||||
namespace :migrations do
|
||||
desc "Migrates context of valuation taggings"
|
||||
task valuation_taggings: :environment do
|
||||
ApplicationLogger.new.info "Updating valuation taggings context"
|
||||
Tagging.where(context: "valuation").update_all(context: "valuation_tags")
|
||||
end
|
||||
|
||||
desc "Migrates budget staff"
|
||||
task budget_admins_and_valuators: :environment do
|
||||
ApplicationLogger.new.info "Updating budget administrators and valuators"
|
||||
Budget.find_each do |budget|
|
||||
investments = budget.investments.with_hidden
|
||||
|
||||
budget.update!(
|
||||
administrator_ids: investments.where.not(administrator: nil).distinct.pluck(:administrator_id),
|
||||
valuator_ids: Budget::ValuatorAssignment.where(investment: investments).distinct.pluck(:valuator_id)
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,29 +0,0 @@
|
||||
namespace :secrets do
|
||||
desc "Add SMTP, SSL and delay jobs settings to secrets.yml"
|
||||
task smtp_ssl_and_delay_jobs: :environment do
|
||||
current_settings = {
|
||||
"mailer_delivery_method" => ActionMailer::Base.delivery_method,
|
||||
"smtp_settings" => ActionMailer::Base.smtp_settings,
|
||||
"force_ssl" => Rails.application.config.force_ssl,
|
||||
"delay_jobs" => Delayed::Worker.delay_jobs
|
||||
}
|
||||
|
||||
settings_to_add = current_settings.select do |name, _|
|
||||
Rails.application.secrets[name].nil?
|
||||
end
|
||||
|
||||
exit if settings_to_add.empty?
|
||||
|
||||
secrets = Rails.application.config.paths["config/secrets"].first
|
||||
stream = Psych.parse_stream(File.read(secrets))
|
||||
nodes = stream.children.first.children.first
|
||||
|
||||
environment_index = nodes.children.index do |child|
|
||||
child.is_a?(Psych::Nodes::Scalar) && child.value == Rails.env
|
||||
end
|
||||
|
||||
nodes.children[environment_index + 1].children.push(*Psych.parse(settings_to_add.to_yaml).children.first.children)
|
||||
|
||||
File.open(secrets, "w") { |file| file.write stream.to_yaml }
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user