Module: DataMapper::Migrations::Model

### Home Classes Methods

### In Files

- lib/dm-migrations/auto_migration.rb

### Methods

- ::included
- #auto_migrate!
- #auto_migrate_down!
- #auto_migrate_up!
- #auto_upgrade!
- #storage_exists?

### Files

- LICENSE
- README.rdoc

### Class/Module Index

Quicksearch

- DataMapper
- DataMapper::Adapters
- DataMapper::Migration
- DataMapper::MigrationRunner
- DataMapper::Migrations
- DataMapper::Migrations::DataObjectsAdapter
- DataMapper::Migrations::DataObjectsAdapter::ClassMethods
- DataMapper::Migrations::DuplicateMigration
- DataMapper::Migrations::Model
- DataMapper::Migrations::MysqlAdapter
- DataMapper::Migrations::MysqlAdapter::ClassMethods
- DataMapper::Migrations::OracleAdapter
- DataMapper::Migrations::OracleAdapter::ClassMethods
- DataMapper::Migrations::PostgresAdapter
- DataMapper::Migrations::PostgresAdapter::ClassMethods
- DataMapper::Migrations::Repository
- DataMapper::Migrations::SingletonMethods
- DataMapper::Migrations::SqliteAdapter
- DataMapper::Migrations::SqliteAdapter::ClassMethods
- DataMapper::Migrations::SqlserverAdapter
- DataMapper::Migrations::SqlserverAdapter::ClassMethods
- DataMapper::Migrations::YamlAdapter
- SQL
- SQL::Column
- SQL::Mysql
- SQL::Mysql::Column
- SQL::Mysql::Table
- SQL::Postgres
- SQL::Postgres::Column
- SQL::Postgres::Table
- SQL::Sqlite
- SQL::Sqlite::Column
- SQL::Sqlite::Table
- SQL::Table
- SQL::TableCreator
- SQL::TableCreator::Column
- SQL::TableCreator::SqlExpr
- SQL::TableModifier
- Spec
- Spec::Example
- Spec::Example::MigrationExampleGroup
- Spec::Matchers
- Spec::Matchers::Migration
- Spec::Matchers::Migration::HaveColumnMatcher
- Spec::Matchers::Migration::HaveTableMatcher
- Spec::Matchers::Migration::NullableColumnMatcher
- Spec::Matchers::Migration::PrimaryKeyMatcher
- Object

No matching classes.

# DataMapper::Migrations::Model

### Public Class Methods

included(mod) click to toggle source

@api private

    # File lib/dm-migrations/auto_migration.rb, line 114
    def self.included(mod)
      mod.descendants.each { |model| model.extend self }
    end

### Public Instance Methods

auto_migrate!(repository_name = self.repository_name) click to toggle source

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

@param Symbol repository_name the repository to be migrated

@api public

    # 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) click to toggle source

Destructively migrates the data-store down, which basically deletes all the models. REPEAT: THIS IS DESTRUCTIVE

@param Symbol repository_name the repository to be migrated

@api private

    # 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) click to toggle source

Auto migrates the data-store to match the model

@param Symbol repository_name the repository to be migrated

@api private

    # 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) click to toggle source

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

@param Symbol repository_name the repository to be migrated

@api public

    # 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) click to toggle source

@api semipublic

    # 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

[Validate]

Generated with the Darkfish Rdoc Generator 2.