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
451 452 453 454 455 456 457 458 459 460 461 |
# File 'lib/dm-core/adapters/data_objects_adapter.rb', line 451 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
464 465 466 467 |
# File 'lib/dm-core/adapters/data_objects_adapter.rb', line 464 def destroy_model_storage(repository, model) execute(drop_table_statement(repository, model)) true end |
#transaction_primitive ⇒ Object
TODO: move to dm-more/dm-transactions
470 471 472 |
# File 'lib/dm-core/adapters/data_objects_adapter.rb', line 470 def transaction_primitive DataObjects::Transaction.create_for_uri(@uri) end |
#upgrade_model_storage(repository, model) ⇒ Object
TODO: move to dm-more/dm-migrations
430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 |
# File 'lib/dm-core/adapters/data_objects_adapter.rb', line 430 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 |