Class: ActiveRecord::ConnectionAdapters::SchemaDefinition

Inherits:
Struct
  • Object
show all
Includes:
SchemaProcs
Defined in:
lib/connection_adapters/schema_definition.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from SchemaProcs

#behavior, #cascade_or_restrict, #definer_or_invoker, #strict_or_null

Instance Attribute Details

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



3
4
5
# File 'lib/connection_adapters/schema_definition.rb', line 3

def name
  @name
end

#ownerObject

Returns the value of attribute owner

Returns:

  • (Object)

    the current value of owner



3
4
5
# File 'lib/connection_adapters/schema_definition.rb', line 3

def owner
  @owner
end

Instance Method Details

#to_rdlObject



6
7
8
# File 'lib/connection_adapters/schema_definition.rb', line 6

def to_rdl
  "  create_schema #{name.to_sql_name}, #{owner.to_sql_name}"
end

#to_sql(action = "create", options = {}) ⇒ Object

CREATE SCHEMA schemaname [ AUTHORIZATION username ] [ schema_element [ … ] ]

DROP SCHEMA [ IF EXISTS ] name [, ...] [ CASCADE | RESTRICT ]


12
13
14
15
16
17
18
19
20
21
# File 'lib/connection_adapters/schema_definition.rb', line 12

def to_sql(action="create", options={})
  case action
    when "create", :create
        "CREATE SCHEMA #{name.to_sql_name} AUTHORIZATION #{owner.to_sql_name}"
    # TODO - [ schema_element ]
    when "drop", :drop
      "DROP SCHEMA #{name.to_sql_name} #{cascade_or_restrict(options[:cascade])}"
    # TODO - [ IF EXISTS ]
  end
end