Module: ActiveGraph::Migrations::Schema

Defined in:
lib/active_graph/migrations/schema.rb

Class Method Summary collapse

Class Method Details

.fetch_schema_dataObject



5
6
7
# File 'lib/active_graph/migrations/schema.rb', line 5

def fetch_schema_data
  { constraints: fetch_constraint_descriptions.sort, indexes: fetch_index_descriptions.sort }
end

.synchronize_schema_data(schema_data, remove_missing) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/active_graph/migrations/schema.rb', line 9

def synchronize_schema_data(schema_data, remove_missing)
  queries = []
  ActiveGraph::Base.read_transaction do
    queries += drop_and_create_queries(fetch_constraint_descriptions, schema_data[:constraints], remove_missing)
    queries += drop_and_create_queries(fetch_index_descriptions, schema_data[:indexes], remove_missing)
  end
  ActiveGraph::Base.write_transaction do
    queries.each(&ActiveGraph::Base.method(:query))
  end
end