Remove tasks to upgrade to version 1.3.0
These tasks are not needed for new installations, and in existing installations they've already been executed when upgrading to version 1.3.0.
This commit is contained in:
@@ -10,59 +10,4 @@ namespace :budgets do
|
||||
Budget.last.email_unselected
|
||||
end
|
||||
end
|
||||
|
||||
desc "Set published attribute"
|
||||
task set_published: :environment do
|
||||
Budget.where(published: nil).each do |budget|
|
||||
if budget.phase == "drafting"
|
||||
if budget.phases.enabled.first.present?
|
||||
next_enabled_phase = budget.phases.enabled.where.not(kind: "drafting").first.kind
|
||||
else
|
||||
next_enabled_phase = "informing"
|
||||
budget.phases.informing.update!(enabled: true)
|
||||
end
|
||||
|
||||
budget.update!(phase: next_enabled_phase)
|
||||
budget.update!(published: false)
|
||||
else
|
||||
budget.update!(published: true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
desc "Copies the Budget::Phase summary into description"
|
||||
task phases_summary_to_description: :environment do
|
||||
ApplicationLogger.new.info "Adding budget phases summary to descriptions"
|
||||
|
||||
Budget::Phase::Translation.find_each do |translation|
|
||||
if translation.summary.present?
|
||||
translation.description << "<br>"
|
||||
translation.description << translation.summary
|
||||
translation.update!(summary: nil) if translation.save
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
desc "Add name to existing budget phases"
|
||||
task add_name_to_existing_phases: :environment do
|
||||
ApplicationLogger.new.info "Adding names to budgets phases"
|
||||
|
||||
Budget::Phase.find_each do |phase|
|
||||
if phase.translations.present?
|
||||
phase.translations.each do |translation|
|
||||
unless translation.name.present?
|
||||
if I18n.available_locales.include? translation.locale
|
||||
locale = translation.locale
|
||||
else
|
||||
locale = I18n.default_locale
|
||||
end
|
||||
|
||||
translation.update!(name: I18n.t("budgets.phase.#{phase.kind}", locale: locale))
|
||||
end
|
||||
end
|
||||
else
|
||||
phase.translations.create!(name: I18n.t("budgets.phase.#{phase.kind}"), locale: I18n.default_locale)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -8,13 +8,4 @@ namespace :consul do
|
||||
task "execute_release_1.4.0_tasks": [
|
||||
"active_storage:migrate_from_paperclip"
|
||||
]
|
||||
|
||||
desc "Runs tasks needed to upgrade from 1.2.0 to 1.3.0"
|
||||
task "execute_release_1.3.0_tasks": [
|
||||
"db:load_sdg",
|
||||
"db:calculate_tsv",
|
||||
"budgets:set_published",
|
||||
"budgets:phases_summary_to_description",
|
||||
"budgets:add_name_to_existing_phases"
|
||||
]
|
||||
end
|
||||
|
||||
@@ -4,17 +4,4 @@ namespace :db do
|
||||
@avoid_log = args[:print_log] == "avoid_log"
|
||||
load(Rails.root.join("db", "dev_seeds.rb"))
|
||||
end
|
||||
|
||||
desc "Load SDG content into database"
|
||||
task load_sdg: :environment do
|
||||
ApplicationLogger.new.info "Adding Sustainable Development Goals content"
|
||||
load(Rails.root.join("db", "sdg.rb"))
|
||||
WebSection.where(name: "sdg").first_or_create!
|
||||
end
|
||||
|
||||
desc "Calculates the TSV column for all polls and legislation processes"
|
||||
task calculate_tsv: :environment do
|
||||
Poll.find_each(&:calculate_tsvector)
|
||||
Legislation::Process.find_each(&:calculate_tsvector)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user