Class: Sequel::Postgres::PropertyGraph::Generator::Alter
- Inherits:
-
Sequel::Postgres::PropertyGraph::Generator
- Object
- Sequel::Postgres::PropertyGraph::Generator
- Sequel::Postgres::PropertyGraph::Generator::Alter
- Defined in:
- lib/sequel/adapters/shared/postgres.rb
Overview
Alter is used to evaluate the block given to DatabaseMethods#alter_property_graph, used to specify changes to an existing property graph.
Constant Summary
Constants inherited from Sequel::Postgres::PropertyGraph::Generator
Instance Method Summary collapse
-
#add_edge(name, opts = OPTS, &block) ⇒ Object
Add an edge to the property graph, with the block used to configure the edge.
-
#add_vertex(name, opts = OPTS, &block) ⇒ Object
Add a vertex to the property graph, with the block used to configure the vertex.
-
#alter_edge_table(name, &block) ⇒ Object
Modify an existing edge table (referenced by its alias).
-
#alter_vertex_table(name, &block) ⇒ Object
Modify an existing vertex table (referenced by its alias).
- #data ⇒ Object
-
#drop_edge_tables(aliases, opts = OPTS) ⇒ Object
Remove edge tables (referenced by their aliases) from the property graph.
-
#drop_vertex_tables(aliases, opts = OPTS) ⇒ Object
Remove vertex tables (referenced by their aliases) from the property graph.
-
#initialize(&block) ⇒ Alter
constructor
A new instance of Alter.
-
#set_owner(new_owner) ⇒ Object
Change the owner of the property graph.
Methods inherited from Sequel::Postgres::PropertyGraph::Generator
Constructor Details
#initialize(&block) ⇒ Alter
Returns a new instance of Alter.
527 528 529 530 531 532 533 534 535 536 537 538 539 540 |
# File 'lib/sequel/adapters/shared/postgres.rb', line 527 def initialize(&block) @operations = [] instance_exec(&block) @operations.each do |op| case op[:op] when :add_vertex_tables, :add_edge_tables op[:tables].freeze end op.freeze end @operations.freeze freeze end |
Instance Method Details
#add_edge(name, opts = OPTS, &block) ⇒ Object
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)
560 561 562 563 |
# File 'lib/sequel/adapters/shared/postgres.rb', line 560 def add_edge(name, opts=OPTS, &block) add_tables_operation(:add_edge_tables) << Edge.new(name, opts, &block) nil end |
#add_vertex(name, opts = OPTS, &block) ⇒ Object
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)
551 552 553 554 |
# File 'lib/sequel/adapters/shared/postgres.rb', line 551 def add_vertex(name, opts=OPTS, &block) add_tables_operation(:add_vertex_tables) << Vertex.new(name, opts, &block) nil end |
#alter_edge_table(name, &block) ⇒ Object
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
600 601 602 603 |
# File 'lib/sequel/adapters/shared/postgres.rb', line 600 def alter_edge_table(name, &block) @operations.concat(AlterElement.new(:edge, name, &block)) nil end |
#alter_vertex_table(name, &block) ⇒ Object
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
591 592 593 594 |
# File 'lib/sequel/adapters/shared/postgres.rb', line 591 def alter_vertex_table(name, &block) @operations.concat(AlterElement.new(:vertex, name, &block)) nil end |
#data ⇒ Object
542 543 544 |
# File 'lib/sequel/adapters/shared/postgres.rb', line 542 def data @operations end |
#drop_edge_tables(aliases, opts = OPTS) ⇒ Object
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)
582 583 584 585 |
# File 'lib/sequel/adapters/shared/postgres.rb', line 582 def drop_edge_tables(aliases, opts=OPTS) @operations << {:op=>:drop_edge_tables, :aliases=>Array(aliases), :cascade=>opts[:cascade]} nil end |
#drop_vertex_tables(aliases, opts = OPTS) ⇒ Object
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)
572 573 574 575 |
# File 'lib/sequel/adapters/shared/postgres.rb', line 572 def drop_vertex_tables(aliases, opts=OPTS) @operations << {:op=>:drop_vertex_tables, :aliases=>Array(aliases), :cascade=>opts[:cascade]} nil end |
#set_owner(new_owner) ⇒ Object
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
612 613 614 615 |
# File 'lib/sequel/adapters/shared/postgres.rb', line 612 def set_owner(new_owner) @operations << {:op=>:set_owner, :owner=>new_owner} nil end |