Module: SeedMigrator
- Includes:
- UpdateClassLoader
- Defined in:
- lib/seed_migrator.rb,
lib/seed_migrator/seeds.rb,
lib/seed_migrator/updater.rb,
lib/seed_migrator/update_class_loader.rb
Overview
Extends the migrations DSL to include the functionality to execute data updates.
Note that each data update class is instantiated regardless of whether it is expected to run. This enables the developer to discover any data update that is incorrectly referenced in a migration, prior to deployment to production.
Defined Under Namespace
Modules: ActiveRecordMigrationCompatible, Seeds, UpdateClassLoader Classes: CreateGenerator, InstallGenerator, Updater
Instance Method Summary collapse
-
#apply_update(update_name) ⇒ Object
Applies the given update.
-
#revert_update(update_name) ⇒ Object
Reverts the given update.
-
#root_updates_path ⇒ Object
Returns the root data updates path.
-
#should_run?(update_name) ⇒ Boolean
Return
true
if the named update should run,false
otherwise.
Methods included from UpdateClassLoader
Instance Method Details
#apply_update(update_name) ⇒ Object
Applies the given update.
28 29 30 |
# File 'lib/seed_migrator.rb', line 28 def apply_update(update_name) perform(update_name, :perform_update) end |
#revert_update(update_name) ⇒ Object
Reverts the given update.
34 35 36 |
# File 'lib/seed_migrator.rb', line 34 def revert_update(update_name) perform(update_name, :undo_update) end |
#root_updates_path ⇒ Object
Returns the root data updates path.
16 17 18 |
# File 'lib/seed_migrator.rb', line 16 def root_updates_path raise "Must override in subclass!" end |
#should_run?(update_name) ⇒ Boolean
Return true
if the named update should run, false
otherwise. Subclasses are expected to override this as needed.
22 23 24 |
# File 'lib/seed_migrator.rb', line 22 def should_run?(update_name) true end |