module Cequel::Record::Schema::ClassMethods
Methods available on {Record} class singletons to introspect and modify the schema defined in the database
Public Instance Methods
read_schema()
click to toggle source
Read the current state of this record's table in Cassandra from the database.
@return [Schema::Table] the current schema assigned to this record's
table in the database
# File lib/cequel/record/schema.rb, line 109 def read_schema table_reader.read end
synchronize_schema()
click to toggle source
Read the current schema assigned to this record's table from Cassandra, and make any necessary modifications (including creating the table for the first time) so that it matches the schema defined in the record definition
@raise (see Schema::TableSynchronizer.apply) @return [void]
# File lib/cequel/record/schema.rb, line 81 def synchronize_schema fail MissingTableNameError unless table_name patch = begin existing_table_descriptor = Cequel::Schema::TableReader.read(connection, table_name) return if existing_table_descriptor.materialized_view? Cequel::Schema::TableDiffer.new(existing_table_descriptor, table_schema) .call rescue NoSuchTableError Cequel::Schema::TableWriter.new(table_schema) end patch.statements.each { |stmt| connection.execute(stmt) } end
table_schema()
click to toggle source
@return [Schema::Table] the schema as defined by the columns
specified in the class definition
# File lib/cequel/record/schema.rb, line 117 def table_schema dsl.table end
Protected Instance Methods
column(name, type, options = {})
click to toggle source
Calls superclass method
# File lib/cequel/record/schema.rb, line 136 def column(name, type, options = {}) super dsl.column(name, type, options) end
compact_storage()
click to toggle source
# File lib/cequel/record/schema.rb, line 160 def compact_storage dsl.compact_storage end
dsl()
click to toggle source
# File lib/cequel/record/schema.rb, line 123 def dsl @dsl ||= Cequel::Schema::TableDescDsl.new(table_name) end
key(name, type, options = {})
click to toggle source
Calls superclass method
# File lib/cequel/record/schema.rb, line 127 def key(name, type, options = {}) super if options[:partition] dsl.partition_key(name, type) else dsl.key(name, type, options[:order]) end end
list(name, type, options = {})
click to toggle source
Calls superclass method
# File lib/cequel/record/schema.rb, line 141 def list(name, type, options = {}) super dsl.list(name, type) end
map(name, key_type, value_type, options = {})
click to toggle source
Calls superclass method
# File lib/cequel/record/schema.rb, line 151 def map(name, key_type, value_type, options = {}) super dsl.map(name, key_type, value_type) end
set(name, type, options = {})
click to toggle source
Calls superclass method
# File lib/cequel/record/schema.rb, line 146 def set(name, type, options = {}) super dsl.set(name, type) end
table_property(name, value)
click to toggle source
# File lib/cequel/record/schema.rb, line 156 def table_property(name, value) dsl.with(name, value) end