Module: DataMapper::Migrations::SimpledbAdapter

Defined in:
lib/dm-adapter-simpledb/migrations/simpledb_adapter.rb

Overview

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(other) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/dm-adapter-simpledb/migrations/simpledb_adapter.rb', line 10

def self.included(other)
  other.extend ClassMethods

  DataMapper.extend(::DataMapper::Migrations::SingletonMethods)

  [ :Repository, :Model ].each do |name|
    ::DataMapper.const_get(name).send(:include, Migrations.const_get(name))
  end
end

Instance Method Details

#create_model_storage(model) ⇒ Object



28
29
30
# File 'lib/dm-adapter-simpledb/migrations/simpledb_adapter.rb', line 28

def create_model_storage(model)
  sdb.create_domain(@sdb_options[:domain])
end

#destroy_model_storage(model) ⇒ Object

On SimpleDB you probably don’t want to destroy the whole domain if you are just adding fields it is automatically supported default to non destructive migrate, to destroy run rake db:automigrate destroy=true



36
37
38
39
40
# File 'lib/dm-adapter-simpledb/migrations/simpledb_adapter.rb', line 36

def destroy_model_storage(model)
  if ENV['destroy']!=nil && ENV['destroy']=='true'
    sdb.delete_domain(@sdb_options[:domain])
  end
end

#storage_exists?(storage_name) ⇒ Boolean

Returns whether the storage_name exists.

Parameters:

  • storage_name (String)

    a String defining the name of a domain

Returns:

  • (Boolean)

    true if the storage exists



23
24
25
26
# File 'lib/dm-adapter-simpledb/migrations/simpledb_adapter.rb', line 23

def storage_exists?(storage_name)
  domains = sdb.list_domains[:domains]
  domains.detect {|d| d == storage_name }!=nil
end