Module: DataMapper::Migrations::Repository

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

Instance Method Summary collapse

Instance Method Details

#auto_migrate!Object

Destructively automigrates the data-store to match the model. First migrates all models down and then up. REPEAT: THIS IS DESTRUCTIVE



96
97
98
# File 'lib/dm-migrations/auto_migration.rb', line 96

def auto_migrate!
  DataMapper.auto_migrate!(name)
end

#auto_upgrade!Object

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



104
105
106
# File 'lib/dm-migrations/auto_migration.rb', line 104

def auto_upgrade!
  DataMapper.auto_upgrade!(name)
end

#create_model_storage(model) ⇒ Object



76
77
78
79
80
81
# File 'lib/dm-migrations/auto_migration.rb', line 76

def create_model_storage(model)
  adapter = self.adapter
  if adapter.respond_to?(:create_model_storage)
    adapter.create_model_storage(model)
  end
end

#destroy_model_storage(model) ⇒ Object



84
85
86
87
88
89
# File 'lib/dm-migrations/auto_migration.rb', line 84

def destroy_model_storage(model)
  adapter = self.adapter
  if adapter.respond_to?(:destroy_model_storage)
    adapter.destroy_model_storage(model)
  end
end

#storage_exists?(storage_name) ⇒ Boolean

Determine whether a particular named storage exists in this repository

Parameters:

  • storage_name (String)

    name of the storage to test for

Returns:

  • (Boolean)

    true if the data-store storage_name exists



60
61
62
63
64
65
# File 'lib/dm-migrations/auto_migration.rb', line 60

def storage_exists?(storage_name)
  adapter = self.adapter
  if adapter.respond_to?(:storage_exists?)
    adapter.storage_exists?(storage_name)
  end
end

#upgrade_model_storage(model) ⇒ Object



68
69
70
71
72
73
# File 'lib/dm-migrations/auto_migration.rb', line 68

def upgrade_model_storage(model)
  adapter = self.adapter
  if adapter.respond_to?(:upgrade_model_storage)
    adapter.upgrade_model_storage(model)
  end
end