Module: DataMapper::Adapters::DataObjectsAdapter::Migration
- Includes:
- SQL
- Included in:
- DataMapper::Adapters::DataObjectsAdapter
- Defined in:
- lib/gems/dm-core-0.9.9/lib/dm-core/adapters/data_objects_adapter.rb
Overview
TODO: move to dm-more/dm-migrations
Defined Under Namespace
Modules: ClassMethods, SQL
Instance Method Summary collapse
-
#create_model_storage(repository, model) ⇒ Object
TODO: move to dm-more/dm-migrations.
-
#destroy_model_storage(repository, model) ⇒ Object
TODO: move to dm-more/dm-migrations.
-
#transaction_primitive ⇒ Object
TODO: move to dm-more/dm-transactions.
-
#upgrade_model_storage(repository, model) ⇒ Object
TODO: move to dm-more/dm-migrations.
Instance Method Details
#create_model_storage(repository, model) ⇒ Object
TODO: move to dm-more/dm-migrations
453 454 455 456 457 458 459 460 461 462 463 |
# File 'lib/gems/dm-core-0.9.9/lib/dm-core/adapters/data_objects_adapter.rb', line 453 def create_model_storage(repository, model) return false if storage_exists?(model.storage_name(repository.name)) execute(create_table_statement(repository, model)) (create_index_statements(repository, model) + create_unique_index_statements(repository, model)).each do |sql| execute(sql) end true end |
#destroy_model_storage(repository, model) ⇒ Object
TODO: move to dm-more/dm-migrations
466 467 468 469 |
# File 'lib/gems/dm-core-0.9.9/lib/dm-core/adapters/data_objects_adapter.rb', line 466 def destroy_model_storage(repository, model) execute(drop_table_statement(repository, model)) true end |
#transaction_primitive ⇒ Object
TODO: move to dm-more/dm-transactions
472 473 474 |
# File 'lib/gems/dm-core-0.9.9/lib/dm-core/adapters/data_objects_adapter.rb', line 472 def transaction_primitive DataObjects::Transaction.create_for_uri(@uri) end |
#upgrade_model_storage(repository, model) ⇒ Object
TODO: move to dm-more/dm-migrations
432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 |
# File 'lib/gems/dm-core-0.9.9/lib/dm-core/adapters/data_objects_adapter.rb', line 432 def upgrade_model_storage(repository, model) table_name = model.storage_name(repository.name) if success = create_model_storage(repository, model) return model.properties(repository.name) end properties = [] model.properties(repository.name).each do |property| schema_hash = property_schema_hash(repository, property) next if field_exists?(table_name, schema_hash[:name]) statement = alter_table_add_column_statement(table_name, schema_hash) execute(statement) properties << property end properties end |