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
  %i[constraints indexes].to_h { |schema_elem| [schema_elem, send("fetch_#{schema_elem}_descriptions").keys] }
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
      drop_and_create_queries(fetch_constraints_descriptions, schema_data[:constraints], 'CONSTRAINT', remove_missing) +
        drop_and_create_queries(fetch_indexes_descriptions, schema_data[:indexes], 'INDEX', remove_missing)
    end
  ActiveGraph::Base.write_transaction do
    queries.each(&ActiveGraph::Base.method(:query))
  end
end