Class: KDomain::DomainModel::Step1DbSchema

Inherits:
Step
  • Object
show all
Defined in:
lib/k_domain/domain_model/transform_steps/step1_db_schema.rb

Instance Attribute Summary

Attributes inherited from Step

#domain_data, #opts, #valid

Instance Method Summary collapse

Methods inherited from Step

#camel, #database, #database=, #database_foreign_keys, #database_tables, #domain, #domain_models, #find_foreign_table, #find_rails_structure_models, #find_table_for_model, #guard, #initialize, #investigate, #issues, #rails_resource, #rails_resource_controllers, #rails_resource_models, #rails_resource_models=, #rails_resource_routes, #rails_resource_routes=, #rails_structure, #rails_structure_controllers, #rails_structure_controllers=, #rails_structure_models, #rails_structure_models=, run, #table_name_exist?, #warning, #write

Constructor Details

This class inherits a constructor from KDomain::DomainModel::Step

Instance Method Details

#callObject

Map database schema to domain model



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/k_domain/domain_model/transform_steps/step1_db_schema.rb', line 7

def call
  raise 'Schema not supplied' if opts[:db_schema].nil?

  self.database = opts[:db_schema].clone
  database[:tables] = database[:tables] # .take(10) # .slice(156, 1)

  guard('tables are missing')               if database[:tables].nil?
  guard('indexes are missing')              if database[:indexes].nil?
  guard('foreign keys are missing')         if database[:foreign_keys].nil?
  guard('rails version is missing')         if database[:meta][:rails].nil?
  guard('postgres extensions are missing')  if database[:meta][:db_info][:extensions].nil?
  guard('unique keys are missing')          if database[:meta][:unique_keys].nil?
end