Class: Alchemy::Upgrader
- Inherits:
-
Object
- Object
- Alchemy::Upgrader
- Includes:
- Shell, Thor::Actions, Thor::Base
- Defined in:
- lib/alchemy/upgrader.rb,
lib/alchemy/upgrader/eight_zero.rb
Defined Under Namespace
Modules: EightZero
Constant Summary collapse
- VERSION_MODULE_MAP =
{ "8.0" => "Alchemy::Upgrader::EightZero" }
Constants included from Shell
Instance Method Summary collapse
-
#initialize(version) ⇒ Upgrader
constructor
A new instance of Upgrader.
- #run_migrations ⇒ Object
- #update_config ⇒ Object
Methods included from Shell
#add_todo, #desc, #display_todos, #log, silence!, silenced?, #todo, #todos, verbose!
Constructor Details
#initialize(version) ⇒ Upgrader
Returns a new instance of Upgrader.
20 21 22 23 |
# File 'lib/alchemy/upgrader.rb', line 20 def initialize(version) super() self.class.include VERSION_MODULE_MAP[version.to_s].constantize end |
Instance Method Details
#run_migrations ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/alchemy/upgrader.rb', line 31 def run_migrations ActiveRecord::Migration.check_all_pending! rescue ActiveRecord::PendingMigrationError desc "Pending Database migrations." if yes?("Run database migrations now? (y/N)") log "Migrating Database..." Rake::Task["db:migrate"].invoke else log "Don't forget to run database migrations later with rake `db:migrate`.", :skip end end |
#update_config ⇒ Object
25 26 27 28 29 |
# File 'lib/alchemy/upgrader.rb', line 25 def update_config desc "Copy configuration file." @default_config = Alchemy::Configurations::Main.new template("templates/alchemy.rb.tt", "config/initializers/alchemy.rb") end |