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.
112 113 114 |
# File 'lib/dm-migrations/auto_migration.rb', line 112 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
127 128 129 130 131 |
# File 'lib/dm-migrations/auto_migration.rb', line 127 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
156 157 158 159 160 161 162 163 164 |
# File 'lib/dm-migrations/auto_migration.rb', line 156 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
171 172 173 174 175 176 177 178 179 |
# File 'lib/dm-migrations/auto_migration.rb', line 171 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
139 140 141 142 143 144 145 146 147 |
# File 'lib/dm-migrations/auto_migration.rb', line 139 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
117 118 119 |
# File 'lib/dm-migrations/auto_migration.rb', line 117 def storage_exists?(repository_name = default_repository_name) repository(repository_name).storage_exists?(storage_name(repository_name)) end |