Remove tasks to upgrade to version 2.0.0
These tasks have already been executed.
This commit is contained in:
@@ -2,12 +2,8 @@ namespace :consul do
|
|||||||
desc "Runs tasks needed to upgrade to the latest version"
|
desc "Runs tasks needed to upgrade to the latest version"
|
||||||
task execute_release_tasks: ["settings:rename_setting_keys",
|
task execute_release_tasks: ["settings:rename_setting_keys",
|
||||||
"settings:add_new_settings",
|
"settings:add_new_settings",
|
||||||
"execute_release_2.0.0_tasks"]
|
"execute_release_2.1.0_tasks"]
|
||||||
|
|
||||||
desc "Runs tasks needed to upgrade from 1.5.0 to 2.0.0"
|
desc "Runs tasks needed to upgrade from 2.0.1 to 2.1.0"
|
||||||
task "execute_release_2.0.0_tasks": [
|
task "execute_release_2.1.0_tasks": []
|
||||||
"db:calculate_tsv",
|
|
||||||
"polls:set_ends_at_to_end_of_day",
|
|
||||||
"db:add_schema_search_path"
|
|
||||||
]
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4,41 +4,4 @@ namespace :db do
|
|||||||
I18n.enforce_available_locales = false
|
I18n.enforce_available_locales = false
|
||||||
Tenant.switch(args[:tenant]) { load(Rails.root.join("db", "dev_seeds.rb")) }
|
Tenant.switch(args[:tenant]) { load(Rails.root.join("db", "dev_seeds.rb")) }
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Calculates the TSV column for all comments and proposal notifications"
|
|
||||||
task calculate_tsv: :environment do
|
|
||||||
logger = ApplicationLogger.new
|
|
||||||
|
|
||||||
logger.info "Calculating tsvector for comments"
|
|
||||||
Comment.with_hidden.find_each(&:calculate_tsvector)
|
|
||||||
|
|
||||||
logger.info "Calculating tsvector for proposal notifications"
|
|
||||||
ProposalNotification.with_hidden.find_each(&:calculate_tsvector)
|
|
||||||
end
|
|
||||||
|
|
||||||
desc "Adds shared extensions to the schema search path in the database.yml file"
|
|
||||||
task add_schema_search_path: :environment do
|
|
||||||
logger = ApplicationLogger.new
|
|
||||||
logger.info "Adding search path to config/database.yml"
|
|
||||||
|
|
||||||
config = Rails.application.config.paths["config/database"].first
|
|
||||||
lines = File.readlines(config)
|
|
||||||
changes_done = false
|
|
||||||
|
|
||||||
adapter_indices = lines.map.with_index do |line, index|
|
|
||||||
index if line.start_with?(" adapter: postgresql")
|
|
||||||
end.compact
|
|
||||||
|
|
||||||
adapter_indices.reverse_each do |index|
|
|
||||||
unless lines[index + 1]&.match?("schema_search_path")
|
|
||||||
lines.insert(index + 1, " schema_search_path: \"public,shared_extensions\"\n")
|
|
||||||
changes_done = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if changes_done
|
|
||||||
File.write(config, lines.join)
|
|
||||||
logger.warn "The database search path has been updated. Restart the application to apply the changes."
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
namespace :polls do
|
|
||||||
desc "Changes the polls ending date to the end of the day"
|
|
||||||
task set_ends_at_to_end_of_day: :environment do
|
|
||||||
ApplicationLogger.new.info "Adding time to the date where a poll ends"
|
|
||||||
|
|
||||||
Poll.find_each do |poll|
|
|
||||||
poll.update_column :ends_at, poll.ends_at.end_of_day.beginning_of_minute
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
require "rails_helper"
|
|
||||||
|
|
||||||
describe "rake db:calculate_tsv" do
|
|
||||||
before { Rake::Task["db:calculate_tsv"].reenable }
|
|
||||||
|
|
||||||
let :run_rake_task do
|
|
||||||
Rake.application.invoke_task("db:calculate_tsv")
|
|
||||||
end
|
|
||||||
|
|
||||||
it "calculates the tsvector for comments, including hidden ones" do
|
|
||||||
comment = create(:comment)
|
|
||||||
hidden = create(:comment, :hidden)
|
|
||||||
comment.update_column(:tsv, nil)
|
|
||||||
hidden.update_column(:tsv, nil)
|
|
||||||
|
|
||||||
expect(comment.reload.tsv).to be nil
|
|
||||||
expect(hidden.reload.tsv).to be nil
|
|
||||||
|
|
||||||
run_rake_task
|
|
||||||
|
|
||||||
expect(comment.reload.tsv).not_to be nil
|
|
||||||
expect(hidden.reload.tsv).not_to be nil
|
|
||||||
end
|
|
||||||
|
|
||||||
it "calculates the tsvector for proposal notifications, including hidden ones" do
|
|
||||||
notification = create(:proposal_notification)
|
|
||||||
hidden = create(:proposal_notification, :hidden)
|
|
||||||
notification.update_column(:tsv, nil)
|
|
||||||
hidden.update_column(:tsv, nil)
|
|
||||||
|
|
||||||
expect(notification.reload.tsv).to be nil
|
|
||||||
expect(hidden.reload.tsv).to be nil
|
|
||||||
|
|
||||||
run_rake_task
|
|
||||||
|
|
||||||
expect(notification.reload.tsv).not_to be nil
|
|
||||||
expect(hidden.reload.tsv).not_to be nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
require "rails_helper"
|
|
||||||
|
|
||||||
describe "rake polls:set_ends_at_to_end_of_day" do
|
|
||||||
before { Rake::Task["polls:set_ends_at_to_end_of_day"].reenable }
|
|
||||||
|
|
||||||
let :run_rake_task do
|
|
||||||
Rake.application.invoke_task("polls:set_ends_at_to_end_of_day")
|
|
||||||
end
|
|
||||||
|
|
||||||
it "updates existing polls" do
|
|
||||||
travel_to(Time.zone.local(2015, 7, 15, 13, 32, 13))
|
|
||||||
poll = create(:poll, ends_at: 2.years.from_now)
|
|
||||||
date_poll = create(:poll, ends_at: 3.years.from_now.to_date)
|
|
||||||
|
|
||||||
expect(I18n.l(poll.reload.ends_at, format: :datetime)).to eq "2017-07-15 13:32:13"
|
|
||||||
expect(I18n.l(date_poll.reload.ends_at, format: :datetime)).to eq "2018-07-15 00:00:00"
|
|
||||||
|
|
||||||
run_rake_task
|
|
||||||
|
|
||||||
expect(I18n.l(poll.reload.ends_at, format: :datetime)).to eq "2017-07-15 23:59:00"
|
|
||||||
expect(I18n.l(date_poll.reload.ends_at, format: :datetime)).to eq "2018-07-15 23:59:00"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
Reference in New Issue
Block a user