Module: Delfos::Neo4j::Schema

Extended by:
Schema
Included in:
Schema
Defined in:
lib/delfos/neo4j/schema.rb

Instance Method Summary collapse

Instance Method Details

#ensure_constraints!(required) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/delfos/neo4j/schema.rb', line 7

def ensure_constraints!(required)
  log "-" * 80
  log "checking constraints"
  log Time.now
  log "-" * 80

  if satisfies_constraints?(required)
    log "Neo4j schema constraints satisfied"
  else
    error "-" * 80
    error "Neo4j schema constraints not satisfied - adding"
    error Time.now

    required.each do |label, attribute|
      create_constraint(label, attribute)
    end

    log "-" * 80
    log "Constraints added"
    log Time.now
  end
end