Module: CassandraMigrations::Cassandra::KeyspaceOperations
- Included in:
- CassandraMigrations::Cassandra
- Defined in:
- lib/cassandra_migrations/cassandra/keyspace_operations.rb
Instance Method Summary collapse
- #create_keyspace!(env) ⇒ Object
- #create_keyspace_statement(config) ⇒ Object
- #drop_keyspace!(env) ⇒ Object
Instance Method Details
#create_keyspace!(env) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/cassandra_migrations/cassandra/keyspace_operations.rb', line 9 def create_keyspace!(env) config = Config.configurations[env] execute(create_keyspace_statement(config)) begin use(config.keyspace) rescue StandardError => exception drop_keyspace!(env) raise exception end end |
#create_keyspace_statement(config) ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/cassandra_migrations/cassandra/keyspace_operations.rb', line 20 def create_keyspace_statement(config) validate_config(config) <<-CQL.strip_heredoc CREATE KEYSPACE #{config.keyspace} WITH replication = { 'class': '#{config.replication['class']}', #{(config)} } CQL end |
#drop_keyspace!(env) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/cassandra_migrations/cassandra/keyspace_operations.rb', line 31 def drop_keyspace!(env) config = Config.configurations[env] begin execute("DROP KEYSPACE #{config.keyspace}") rescue ::Cassandra::Errors::ConfigurationError raise Errors::UnexistingKeyspaceError, config.keyspace end end |