cassie 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c69c7faad6e465a92ab097dc7df5a471585694e1
4
- data.tar.gz: cb03bcbb2b28029fd977d9709085b741e6606d60
3
+ metadata.gz: 75bc223d41cf01f427460302177d0d0b5ad5d30d
4
+ data.tar.gz: 34dc615d58b19bc55c5cee0bde387824375ccffc
5
5
  SHA512:
6
- metadata.gz: 4d120d17ebd793fcb0ff7c3387fc3b1b10e6eaaf1003dab3b4b579414582cc47397ffde20c5f2b7fef689e02005f21a528abbe7cf0706f12faf819f60dfc38ac
7
- data.tar.gz: 6f09e37b7e431609c0a8184d494e12a2f9b2e6c39e9f8955149d65653fe2014327204963cae78d55dff83ab8b966484a14ce2bced676c59bac8b0c63d73ab146
6
+ metadata.gz: b0db9476db7746879d6f4118358da035e7ee28feaa5aa9a0055cb14bc93ab9c39d9adc0455df19bda6150588459653728520f3e88376be27e164643fc8d2b0a6
7
+ data.tar.gz: 1414b64d116c5cce2e301790106e3ec2a645119cd5b332e374ae45d59279322a195ae6d7c56ba9447faa201440453fc8a9b6c34881b9089969eb40c0519f42fa
@@ -25,10 +25,26 @@ module Cassie::ConnectionHandler
25
25
  @cluster ||= initialize_cluster
26
26
  end
27
27
 
28
- # @param [String, Symbol] name The keyspace name to search for
28
+ # @param [String, Symbol] name The keyspace name to search for
29
29
  # @return [Boolean] indicating if the cluster has the keyspace defined
30
30
  def keyspace_exists?(name)
31
- Cassie.cluster.keyspaces.map(&:name).any?{|k| k.to_s == name.to_s}
31
+ cluster.keyspaces.map(&:name).any?{|k| k.to_s == name.to_s}
32
+ end
33
+
34
+ # @param [String, Symbol] name The table name to search for. If the name
35
+ # includes a '.', it is assumed to be a fully qualified table name. Otherwise
36
+ # the table name will be searched for in the current namespace
37
+ # @return [Boolean] indicating if the cluster has the keyspace defined
38
+ def table_exists?(name)
39
+ keyspaces = {}
40
+ name = "#{keyspace}.#{name}" unless name.to_s.include? "."
41
+ matches = name.match(/(.*)\.(.*)/)
42
+ space = matches[1]
43
+ table = matches[2]
44
+ cluster.keyspaces.each {|k| keyspaces[k.name.to_s] = k }
45
+
46
+ return false unless keyspaces.has_key?(space)
47
+ keyspaces[space].tables.map(&:name).any?{|t| t.to_s == table}
32
48
  end
33
49
 
34
50
  protected
@@ -33,7 +33,7 @@ module Cassie::Schema
33
33
  # in the Cassandra database if they don't already exist
34
34
  # @return [void]
35
35
  def initialize_versioning
36
- create_schema_keyspace unless keyspace_exists?
36
+ create_schema_keyspace unless schema_keyspace_exists?
37
37
  create_versions_table unless versions_table_exists?
38
38
  end
39
39
 
@@ -109,10 +109,14 @@ module Cassie::Schema
109
109
  '0.0.1.0'
110
110
  end
111
111
 
112
- def keyspace_exists?
112
+ def schema_keyspace_exists?
113
113
  Cassie.keyspace_exists?(Cassie::Schema.schema_keyspace)
114
114
  end
115
115
 
116
+ def versions_table_exists?
117
+ Cassie.table_exists?(qualified_table_name)
118
+ end
119
+
116
120
  # load version migration class from disk
117
121
  def load_applied_versions
118
122
  database_versions.tap do |versions|
@@ -138,12 +142,6 @@ module Cassie::Schema
138
142
  false
139
143
  end
140
144
 
141
- def versions_table_exists?
142
- !!SelectVersionsQuery.new(limit: 1).fetch
143
- rescue Cassandra::Errors::InvalidError
144
- false
145
- end
146
-
147
145
  def create_schema_keyspace
148
146
  CreateKeyspaceQuery.new(name: Cassie::Schema.schema_keyspace).execute
149
147
  end
@@ -157,7 +155,11 @@ module Cassie::Schema
157
155
  end
158
156
 
159
157
  def uninitialized_message
160
- "Cassie Schema Versions table not found at '#{schema_keyspace}.#{versions_table}'. Enable versioned migration support with `cassie schema:init`."
158
+ "Cassie Schema Versions table not found at '#{qualified_table_name}'. Enable versioned migration support with `cassie schema:init`."
159
+ end
160
+
161
+ def qualified_table_name
162
+ "#{schema_keyspace}.#{versions_table}"
161
163
  end
162
164
  end
163
165
  end
@@ -11,7 +11,7 @@ namespace :cassie do
11
11
 
12
12
  query = Cassie::Schema::CreateKeyspaceQuery.new
13
13
  query.name = name
14
- if replicaiton = Cassie.configuration[:replication]
14
+ if replication = Cassie.configuration[:replication]
15
15
  query.replication_class = replication[:class] if replication.has_key?(:class)
16
16
  query.replication_factor = replication[:replication_factor] if replication.has_key?(:replication_factor)
17
17
  end
@@ -1,3 +1,3 @@
1
1
  module Cassie
2
- VERSION = "1.1.0"
2
+ VERSION = "1.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cassie
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan Prothro
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-18 00:00:00.000000000 Z
11
+ date: 2017-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cassandra-driver