Class: Cassie::Schema::Definition::DSL
- Defined in:
- lib/cassie/schema/definition/dsl.rb
Overview
DSL for Cassie::Schema Defintion these methods can be called in a schema.rb file to define keyspace agnostic schema. When executed, they will then create that schema for the currently defined default keyspace found in Cassie.configuration[:keyspace]
.
Class Method Summary collapse
-
.create_schema(cql) ⇒ Cassandra::Result
Execute the given CQL on the current cluster, using an unscoped session.
-
.default_keyspace ⇒ String
The default keyspace according to the cluster configuration in
Cassie.configuration[:keyspace]
. - .record_version(number, description, uuid, executor, executed_at_utc) ⇒ Object
Class Method Details
.create_schema(cql) ⇒ Cassandra::Result
Execute the given CQL on the current cluster, using an unscoped session. CQL should be keyspace agnostic, where keyspace names are interpolated with the #{default_keyspace}. Table names must be fully qualified.
25 26 27 28 29 |
# File 'lib/cassie/schema/definition/dsl.rb', line 25 def create_schema(cql) cql.strip.split(";").each do |statement| Cassie.session(nil).execute("#{statement.strip};") end end |
.default_keyspace ⇒ String
The default keyspace according to the cluster configuration in Cassie.configuration[:keyspace]
16 17 18 |
# File 'lib/cassie/schema/definition/dsl.rb', line 16 def default_keyspace Cassie.configuration[:keyspace] end |
.record_version(number, description, uuid, executor, executed_at_utc) ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/cassie/schema/definition/dsl.rb', line 31 def record_version(number, description, uuid, executor, executed_at_utc) id = Cassandra::TimeUuid.new(uuid) executed_at = DateTime.parse(executed_at_utc) rescue nil version = Version.new(number, description, id, executor, executed_at) Cassie::Schema.initialize_versioning Cassie::Schema.record_version(version) end |