Module: DataMapper::AutoMigrations
- Defined in:
- lib/dm-core/auto_migrations.rb
Overview
class AutoMigrator
Instance Method Summary collapse
-
#auto_migrate!(repository_name = self.repository_name) ⇒ Object
Destructively automigrates the data-store to match the model REPEAT: THIS IS DESTRUCTIVE.
-
#auto_migrate_down!(repository_name = self.repository_name) ⇒ Object
private
Destructively migrates the data-store down, which basically deletes all the models.
-
#auto_migrate_up!(repository_name = self.repository_name) ⇒ Object
private
Auto migrates the data-store to match the model.
-
#auto_upgrade!(repository_name = self.repository_name) ⇒ Object
Safely migrates the data-store to match the model preserving data already in the data-store.
Instance Method Details
#auto_migrate!(repository_name = self.repository_name) ⇒ Object
Destructively automigrates the data-store to match the model REPEAT: THIS IS DESTRUCTIVE
62 63 64 65 |
# File 'lib/dm-core/auto_migrations.rb', line 62 def auto_migrate!(repository_name = self.repository_name) auto_migrate_down!(repository_name) auto_migrate_up!(repository_name) end |
#auto_migrate_down!(repository_name = self.repository_name) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Destructively migrates the data-store down, which basically deletes all the models. REPEAT: THIS IS DESTRUCTIVE
74 75 76 77 78 79 80 81 82 83 |
# File 'lib/dm-core/auto_migrations.rb', line 74 def auto_migrate_down!(repository_name = self.repository_name) # repository_name ||= default_repository_name if self.superclass != Object self.superclass.auto_migrate!(repository_name) else repository(repository_name) do |r| r.adapter.destroy_model_storage(r, self) end end end |
#auto_migrate_up!(repository_name = self.repository_name) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Auto migrates the data-store to match the model
90 91 92 93 94 95 96 97 98 |
# File 'lib/dm-core/auto_migrations.rb', line 90 def auto_migrate_up!(repository_name = self.repository_name) if self.superclass != Object self.superclass.auto_migrate!(repository_name) else repository(repository_name) do |r| r.adapter.create_model_storage(r, self) end end end |
#auto_upgrade!(repository_name = self.repository_name) ⇒ Object
Safely migrates the data-store to match the model preserving data already in the data-store
105 106 107 108 109 |
# File 'lib/dm-core/auto_migrations.rb', line 105 def auto_upgrade!(repository_name = self.repository_name) repository(repository_name) do |r| r.adapter.upgrade_model_storage(r, self) end end |