Module: DataMapper::Adapters::DataObjectsAdapter::Migration
- Includes:
- SQL
- Included in:
- DataMapper::Adapters::DataObjectsAdapter
- Defined in:
- 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
460 461 462 463 464 465 466 467 468 469 470 |
# File 'lib/dm-core/adapters/data_objects_adapter.rb', line 460 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
473 474 475 476 |
# File 'lib/dm-core/adapters/data_objects_adapter.rb', line 473 def destroy_model_storage(repository, model) execute(drop_table_statement(repository, model)) true end |
#transaction_primitive ⇒ Object
TODO: move to dm-more/dm-transactions
479 480 481 |
# File 'lib/dm-core/adapters/data_objects_adapter.rb', line 479 def transaction_primitive DataObjects::Transaction.create_for_uri(@uri) end |
#upgrade_model_storage(repository, model) ⇒ Object
TODO: move to dm-more/dm-migrations
439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 |
# File 'lib/dm-core/adapters/data_objects_adapter.rb', line 439 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 |