-
-
Notifications
You must be signed in to change notification settings - Fork 315
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Since the acts-as-taggable-on migrations make use of the ActsAsTaggableOn class, we want to skip the tasks inside of these migrations. We renamed the tables anyway, but in order to be able to re-run these migrations without harm it makes sense to skip these migrations.
- Loading branch information
Showing
3 changed files
with
80 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
require_relative 'tasks/harden_acts_as_taggable_on_migrations' | ||
|
||
module Alchemy | ||
class Upgrader::FourPointOne < Upgrader | ||
class << self | ||
def harden_acts_as_taggable_on_migrations | ||
desc 'Harden `acts_as_taggable_on_migrations`' | ||
`bundle exec rake railties:install:migrations FROM=acts_as_taggable_on_engine` | ||
Alchemy::Upgrader::Tasks::HardenActsAsTaggableOnMigrations.new.patch_migrations | ||
`bundle exec rake db:migrate` | ||
end | ||
|
||
def alchemy_4_1_todos | ||
notice = <<-NOTE | ||
Changed tagging provider to Gutentag | ||
------------------------------------ | ||
The automatic updater that just ran updated all existing `acts_as_taggable_on_migrations`, | ||
so that they don't blow up if the `acts_as_taggable_on` gem is no longer available. | ||
All your existing tags have been migrated to `Gutentag::Tag`s. | ||
NOTE | ||
todo notice, 'Alchemy v4.1 changes' | ||
end | ||
end | ||
end | ||
end |
27 changes: 27 additions & 0 deletions
27
lib/alchemy/upgrader/tasks/harden_acts_as_taggable_on_migrations.rb
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,27 @@ | ||
require 'thor' | ||
|
||
module Alchemy::Upgrader::Tasks | ||
class HardenActsAsTaggableOnMigrations < Thor | ||
include Thor::Actions | ||
|
||
no_tasks do | ||
def patch_migrations | ||
sentinel = /add_column.*/ | ||
aato_file = Dir.glob('db/migrate/*_add_taggings_counter_cache_to_tags.*.rb').first | ||
if aato_file | ||
inject_into_file aato_file, | ||
"\n\n # inserted by Alchemy CMS upgrader\n return unless defined?(ActsAsTaggableOn)", | ||
{ after: sentinel, verbose: true } | ||
end | ||
|
||
sentinel = /def up/ | ||
aato_file = Dir.glob('db/migrate/*_change_collation_for_tag_names.*.rb').first | ||
if aato_file | ||
inject_into_file aato_file, | ||
"\n # inserted by Alchemy CMS upgrader\n return unless defined?(ActsAsTaggableOn)\n", | ||
{ after: sentinel, verbose: true } | ||
end | ||
end | ||
end | ||
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