class Sequel::Postgres::PropertyGraph::Generator::Alter

  1. lib/sequel/adapters/shared/postgres.rb
Superclass: self

Alter is used to evaluate the block given to DatabaseMethods#alter_property_graph, used to specify changes to an existing property graph.

Public Class methods

new(&block)
[show source]
    # File lib/sequel/adapters/shared/postgres.rb
527 def initialize(&block)
528   @operations = []
529   instance_exec(&block)
530 
531   @operations.each do |op|
532     case op[:op]
533     when :add_vertex_tables, :add_edge_tables
534       op[:tables].freeze
535     end
536     op.freeze
537   end
538   @operations.freeze
539   freeze
540 end

Public Instance methods

add_edge(name, opts=OPTS, &block)

Add an edge to the property graph, with the block used to configure the edge.

alter_property_graph.add_edge(:e){source :v1; destination :v2}
# ADD EDGE TABLES (e SOURCE v1 DESTINATION v2)
[show source]
    # File lib/sequel/adapters/shared/postgres.rb
560 def add_edge(name, opts=OPTS, &block)
561   add_tables_operation(:add_edge_tables) << Edge.new(name, opts, &block)
562   nil
563 end
add_vertex(name, opts=OPTS, &block)

Add a vertex to the property graph, with the block used to configure the vertex.

alter_property_graph.add_vertex(:v)
# ADD VERTEX TABLES (v)
[show source]
    # File lib/sequel/adapters/shared/postgres.rb
551 def add_vertex(name, opts=OPTS, &block)
552   add_tables_operation(:add_vertex_tables) << Vertex.new(name, opts, &block)
553   nil
554 end
alter_edge_table(name, &block)

Modify an existing edge table (referenced by its alias).

alter_property_graph.alter_edge_table(:e, properties: :none){drop_label :l}
# ALTER VERTEX TABLE e DROP LABEL l
[show source]
    # File lib/sequel/adapters/shared/postgres.rb
600 def alter_edge_table(name, &block)
601   @operations.concat(AlterElement.new(:edge, name, &block))
602   nil
603 end
alter_vertex_table(name, &block)

Modify an existing vertex table (referenced by its alias).

alter_property_graph.alter_vertex_table(:v){add_label :l}
# ALTER VERTEX TABLE v ADD LABEL l PROPERTIES ALL COLUMNS
[show source]
    # File lib/sequel/adapters/shared/postgres.rb
591 def alter_vertex_table(name, &block)
592   @operations.concat(AlterElement.new(:vertex, name, &block))
593   nil
594 end
data()
[show source]
    # File lib/sequel/adapters/shared/postgres.rb
542 def data
543   @operations
544 end
drop_edge_tables(aliases, opts=OPTS)

Remove edge tables (referenced by their aliases) from the property graph. See drop_vertex_tables.

alter_property_graph.drop_edge_tables([:e1, :e2])
# DROP EDGE TABLES (e1, e2)
[show source]
    # File lib/sequel/adapters/shared/postgres.rb
582 def drop_edge_tables(aliases, opts=OPTS)
583   @operations << {:op=>:drop_edge_tables, :aliases=>Array(aliases), :cascade=>opts[:cascade]}
584   nil
585 end
drop_vertex_tables(aliases, opts=OPTS)

Remove vertex tables (referenced by their aliases) from the property graph. aliases can be a single alias or an array. Options:

:cascade

Use CASCADE instead of the default RESTRICT.

alter_property_graph.drop_vertex_tables([:v1, :v2])
# DROP VERTEX TABLES (v1, v2)
[show source]
    # File lib/sequel/adapters/shared/postgres.rb
572 def drop_vertex_tables(aliases, opts=OPTS)
573   @operations << {:op=>:drop_vertex_tables, :aliases=>Array(aliases), :cascade=>opts[:cascade]}
574   nil
575 end
set_owner(new_owner)

Change the owner of the property graph. new_owner is usually a Symbol or SQL::Identifier for the role name, but can be Sequel.lit('CURRENT_USER') or Sequel.lit('SESSION_USER').

alter_property_graph.owner_to(:new_owner)
# OWNER TO new_owner
[show source]
    # File lib/sequel/adapters/shared/postgres.rb
612 def set_owner(new_owner)
613   @operations << {:op=>:set_owner, :owner=>new_owner}
614   nil
615 end