Sha256: c3c34b83494f857583914b04e8b30a39ceaaebab5fbfa454860cbc99b4d48c10

Contents?: true

Size: 1.9 KB

Versions: 5

Compression:

Stored size: 1.9 KB

Contents

require 'thor'

class Alchemy::Upgrader::ThreePointTwoTask < Thor
  include Thor::Actions

  no_tasks do

    def patch_acts_as_taggable_on_migrations
      sentinel = /def self.up/

      aato_file = Dir.glob('db/migrate/*_acts_as_taggable_on_migration.*.rb').first
      if aato_file
        inject_into_file aato_file,
          "\n    # inserted by Alchemy CMS upgrader\n    return if table_exists?(:tags)\n",
          { after: sentinel, verbose: true }
      end

      aato_file = Dir.glob('db/migrate/*_add_missing_unique_indices.*.rb').first
      if aato_file
        inject_into_file aato_file,
          "\n    # inserted by Alchemy CMS upgrader\n    return if index_exists?(:tags, :name)\n",
          { after: sentinel, verbose: true }
      end
    end

    def inject_seeder
      append_file "./db/seeds.rb", "Alchemy::Seeder.seed!\n"
    end
  end
end

module Alchemy
  module Upgrader::ThreePointTwo
    private

    def upgrade_acts_as_taggable_on_migrations
      desc 'Installs acts_as_taggable_on migrations.'
      if !`bundle exec rake railties:install:migrations FROM=acts_as_taggable_on_engine`.empty?
        Alchemy::Upgrader::ThreePointTwoTask.new.patch_acts_as_taggable_on_migrations
      end
      `bundle exec rake db:migrate`
    end

    def inject_seeder
      desc 'Add Alchemy seeder to `db/seeds.rb` file.'
      Alchemy::Upgrader::ThreePointTwoTask.new.inject_seeder
    end

    def alchemy_3_2_todos
      notice = <<-NOTE

Capistrano 2 deploy script removed
----------------------------------

The Capistrano 2 based deploy script has been removed and replaced by an Capistrano 3 extension.

Please update your Gemfile:

group :development do
  gem 'capistrano-alchemy', github: 'AlchemyCMS/capistrano-alchemy', branch: 'master', require: false
end

For more information please visit https://github.com/AlchemyCMS/capistrano-alchemy.

NOTE
      todo notice, 'Alchemy v3.2 changes'
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
alchemy_cms-3.2.1 lib/alchemy/upgrader/three_point_two.rb
lc_alchemy_cms-3.2.1 lib/alchemy/upgrader/three_point_two.rb
lc_alchemy_cms-3.2.0 lib/alchemy/upgrader/three_point_two.rb
alchemy_cms-3.2.0 lib/alchemy/upgrader/three_point_two.rb
alchemy_cms-3.2.0.rc1 lib/alchemy/upgrader/three_point_two.rb