Skip to content

Commit

Permalink
Remove the upgrade task and point to additional steps from the update…
Browse files Browse the repository at this point in the history
… generator

Having both an `upgrade` task and an `update` generator is confusing. On
top of that, it's better to have actionable items, which can be
undesirable in some situations, the most explicit as possible. For this
reason, we leave in place the `update` generator, which is just a safe
path to update preferences, and remove the `upgrade` task. Instead, we
add a generic message into the `update` generator pointing to the
detailed instructions in the Changelog.

In particular, at this point, the `update` task was calling to a single
task introduced in solidusio#3987. We still keep the task reachable by end-users,
but we rename it slightly to be more friendly.
  • Loading branch information
waiting-for-dev authored and biximilien committed Sep 9, 2021
1 parent 2e3552f commit 66f6589
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 39 deletions.
16 changes: 16 additions & 0 deletions core/lib/generators/solidus/update/update_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,22 @@ def create_new_defaults_initializer
File.join(options[:initializer_directory], "#{options[:initializer_basename]}.rb")
end

def print_message
say <<~MSG
***********************************************************************
Other tasks may be needed to update to the new Solidus version. Please,
check https://github.com/solidusio/solidus/blob/v#{options[:to]}/CHANGELOG.md
for details.
Thanks for using Solidus!
***********************************************************************
MSG
end

private

def core_changes_template(from, to)
Expand Down
13 changes: 0 additions & 13 deletions core/lib/tasks/migrations/delete_prices_with_nil_amount.rake

This file was deleted.

8 changes: 8 additions & 0 deletions core/lib/tasks/solidus/delete_prices_with_nil_amount.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# frozen_string_literal: true

namespace :solidus do
desc "Delete Spree::Price records which amount field is NULL"
task delete_prices_with_nil_amount: :environment do
Spree::Price.where(amount: nil).delete_all
end
end
22 changes: 0 additions & 22 deletions core/lib/tasks/upgrade.rake

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

require 'rails_helper'

path = Spree::Core::Engine.root.join('lib/tasks/migrations/delete_prices_with_nil_amount.rake')
path = Spree::Core::Engine.root.join('lib/tasks/solidus/delete_prices_with_nil_amount.rake')

RSpec.describe 'solidus:migrations:delete_prices_with_nil_amount' do
describe 'up' do
RSpec.describe 'solidus' do
describe 'delete_prices_with_nil_amount' do
include_context(
'rake',
task_path: path,
task_name: 'solidus:migrations:delete_prices_with_nil_amount:up'
task_name: 'solidus:delete_prices_with_nil_amount'
)

it 'removes all prices which amount column is NULL' do
Expand Down

0 comments on commit 66f6589

Please sign in to comment.