Module: DataMapper::Migrations::Model

Defined in:
lib/dm-migrations/auto_migration.rb

Overview

module Repository

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Object) included(mod)

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

- (Object) auto_migrate!(repository_name = self.repository_name)

Destructively automigrates the data-store to match the model REPEAT: THIS IS DESTRUCTIVE

Parameters:

  • Symbol

    repository_name the repository to be migrated



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

- (Object) auto_migrate_down!(repository_name = self.repository_name)

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

Parameters:

  • Symbol

    repository_name the repository to be migrated



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

- (Object) auto_migrate_up!(repository_name = self.repository_name)

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

Parameters:

  • Symbol

    repository_name the repository to be migrated



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

- (Object) auto_upgrade!(repository_name = self.repository_name)

Safely migrates the data-store to match the model preserving data already in the data-store

Parameters:

  • Symbol

    repository_name the repository to be migrated



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

- (Boolean) storage_exists?(repository_name = default_repository_name)

Returns:

  • (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