Module: DataMapper::Migrations::Model
- Defined in:
- lib/dm-migrations/auto_migration.rb
Overview
module Repository
Class Method Summary collapse
- .included(mod) ⇒ Object private
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.
- #storage_exists?(repository_name = default_repository_name) ⇒ Boolean
Class Method Details
.included(mod) ⇒ 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.
114 115 116 |
# File 'lib/dm-migrations/auto_migration.rb', line 114 def self.included(mod) mod.descendants.each { |model| model.extend self } end |
Instance Method Details
#auto_migrate!(repository_name = self.repository_name) ⇒ Object
Destructively automigrates the data-store to match the model REPEAT: THIS IS DESTRUCTIVE
129 130 131 132 133 |
# File 'lib/dm-migrations/auto_migration.rb', line 129 def auto_migrate!(repository_name = self.repository_name) assert_valid(true) 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
158 159 160 161 162 163 164 165 166 |
# File 'lib/dm-migrations/auto_migration.rb', line 158 def auto_migrate_down!(repository_name = self.repository_name) assert_valid(true) base_model = self.base_model if base_model == self repository(repository_name).destroy_model_storage(self) else base_model.auto_migrate_down!(repository_name) 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
173 174 175 176 177 178 179 180 181 |
# File 'lib/dm-migrations/auto_migration.rb', line 173 def auto_migrate_up!(repository_name = self.repository_name) assert_valid(true) base_model = self.base_model if base_model == self repository(repository_name).create_model_storage(self) else base_model.auto_migrate_up!(repository_name) 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
141 142 143 144 145 146 147 148 149 |
# File 'lib/dm-migrations/auto_migration.rb', line 141 def auto_upgrade!(repository_name = self.repository_name) assert_valid(true) base_model = self.base_model if base_model == self repository(repository_name).upgrade_model_storage(self) else base_model.auto_upgrade!(repository_name) end end |
#storage_exists?(repository_name = default_repository_name) ⇒ Boolean
119 120 121 |
# File 'lib/dm-migrations/auto_migration.rb', line 119 def storage_exists?(repository_name = default_repository_name) repository(repository_name).storage_exists?(storage_name(repository_name)) end |