Class: Mv::Core::Migration::Base
- Inherits:
-
Object
- Object
- Mv::Core::Migration::Base
- Includes:
- Singleton
- Defined in:
- lib/mv/core/migration/base.rb
Constant Summary collapse
- SUPPORTED_METHODS =
%i{ add_column remove_column rename_column change_column rename_table drop_table}
Instance Attribute Summary collapse
-
#operations_factory ⇒ Object
readonly
Returns the value of attribute operations_factory.
-
#operations_list ⇒ Object
readonly
Returns the value of attribute operations_list.
Instance Method Summary collapse
- #add_column(table_name, column_name, opts) ⇒ Object
- #execute ⇒ Object
-
#initialize ⇒ Base
constructor
A new instance of Base.
- #with_suppressed_validations ⇒ Object
Constructor Details
Instance Attribute Details
#operations_factory ⇒ Object (readonly)
Returns the value of attribute operations_factory.
18 19 20 |
# File 'lib/mv/core/migration/base.rb', line 18 def operations_factory @operations_factory end |
#operations_list ⇒ Object (readonly)
Returns the value of attribute operations_list.
18 19 20 |
# File 'lib/mv/core/migration/base.rb', line 18 def operations_list @operations_list end |
Instance Method Details
#add_column(table_name, column_name, opts) ⇒ Object
57 58 59 60 61 62 63 64 |
# File 'lib/mv/core/migration/base.rb', line 57 def add_column table_name, column_name, opts return unless opts.present? unless disabled_validations? operation = operations_factory.create_operation(:add_column, table_name, column_name, opts) operations_list.add_operation(operation) end end |
#execute ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/mv/core/migration/base.rb', line 35 def execute if operations_list.present? Mv::Core::Services::CreateMigrationValidatorsTable.new.execute constraints_loader = Mv::Core::Services::LoadConstraints.new(operations_list.tables) old_constraints = constraints_loader.execute operations_list.execute() new_constraints = constraints_loader.execute constraints_comparizon = Mv::Core::Services::CompareConstraintArrays.new(old_constraints, new_constraints) .execute Mv::Core::Services::SynchronizeConstraints.new(constraints_comparizon[:added], constraints_comparizon[:updated], constraints_comparizon[:deleted]) .execute end end |
#with_suppressed_validations ⇒ Object
66 67 68 69 70 |
# File 'lib/mv/core/migration/base.rb', line 66 def with_suppressed_validations disable_validations! yield enable_validations! end |