cequel-migrations-rails 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-1.9.3-p327@cequel-migrations-rails
data/README.md CHANGED
@@ -125,6 +125,28 @@ At the moment we currently only provide the `execute` method. However, we plan
125
125
  to provide other helper functions like, `create_column_family`,
126
126
  `drop_column_family`, etc.
127
127
 
128
+ ### Example Migration
129
+
130
+ Below is an example migration which creates a column family in the `up` method
131
+ and drops the column family in the `down` method. Here we can see that the
132
+ migration inherits from the `Cequel::Migrations` and see that we are using the
133
+ execute method to execute CQL strings within the `up` and `down` methods as
134
+ describe above.
135
+
136
+ The migration exists at the following path,
137
+ `cequel/migrate/20121130082818_create_visitor_events_column_family.rb`
138
+ relative to the project root directory.
139
+
140
+ class CreateVisitorEventsColumnFamily < Cequel::Migration
141
+ def up
142
+ execute("CREATE COLUMNFAMILY visitor_events (visitor_id uuid PRIMARY KEY)")
143
+ end
144
+
145
+ def down
146
+ execute("DROP COLUMNFAMILY visitor_events")
147
+ end
148
+ end
149
+
128
150
  ## Contributing
129
151
 
130
152
  1. Fork it
@@ -3,7 +3,7 @@ module Cequel
3
3
  attr_reader :db
4
4
 
5
5
  def initialize
6
- @db = CassandraCQL::Database.new(self.class.cequel_env_conf['host'], { :keyspace => self.class.cequel_env_conf['keyspace'] })
6
+ @db = CassandraCQL::Database.new(servers, { :keyspace => self.class.cequel_env_conf['keyspace'] })
7
7
  end
8
8
 
9
9
  def execute(cql_string)
@@ -13,5 +13,10 @@ module Cequel
13
13
  def self.cequel_env_conf
14
14
  YAML::load(File.open(File.join(::Rails.root,"config", "cequel.yml")))[::Rails.env]
15
15
  end
16
+
17
+ private
18
+ def servers
19
+ self.class.cequel_env_conf['hosts'] || self.class.cequel_env_conf['host']
20
+ end
16
21
  end
17
22
  end
@@ -5,7 +5,7 @@ module Cequel
5
5
  attr_reader :db
6
6
 
7
7
  def initialize
8
- @db = CassandraCQL::Database.new(self.class.cequel_env_conf['host'])
8
+ @db = CassandraCQL::Database.new(servers)
9
9
  end
10
10
 
11
11
  def self.cequel_env_conf
@@ -25,6 +25,10 @@ module Cequel
25
25
  end
26
26
 
27
27
  private
28
+ def servers
29
+ self.class.cequel_env_conf['hosts'] || self.class.cequel_env_conf['host']
30
+ end
31
+
28
32
 
29
33
  def build_create_keyspace_cmd(keyspace_name, strategy_class_name, strategy_options)
30
34
  strat_opts_array = []
@@ -52,4 +52,14 @@ namespace :cequel do
52
52
  Rake::Task["cequel:create"].invoke
53
53
  Rake::Task["cequel:migrate"].invoke
54
54
  end
55
+
56
+ desc "Launches cqlsh command and connects to cassandra server specified in your cequel.yml"
57
+ task :shell do
58
+ keyspace_manager = Cequel::Migrations::Rails::KeyspaceManager.new
59
+ server_parts = keyspace_manager.db.connection.current_server.to_s.split(':')
60
+ server_ip = server_parts[0]
61
+ server_port = server_parts[1]
62
+
63
+ system("cqlsh -k #{Cequel::Migrations::Rails::KeyspaceManager.cequel_env_conf['keyspace']} #{server_ip} #{server_port}")
64
+ end
55
65
  end
@@ -1,7 +1,7 @@
1
1
  module Cequel
2
2
  module Migrations
3
3
  module Rails
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cequel-migrations-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-04 00:00:00.000000000 Z
12
+ date: 2013-05-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: shearwater
@@ -83,7 +83,7 @@ extensions: []
83
83
  extra_rdoc_files: []
84
84
  files:
85
85
  - .gitignore
86
- - .rvmrc
86
+ - .ruby-version
87
87
  - Gemfile
88
88
  - LICENSE.txt
89
89
  - README.md
@@ -121,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
121
  version: '0'
122
122
  requirements: []
123
123
  rubyforge_project:
124
- rubygems_version: 1.8.24
124
+ rubygems_version: 1.8.23
125
125
  signing_key:
126
126
  specification_version: 3
127
127
  summary: A Rails plugin that provides migration support for Cequel.
data/.rvmrc DELETED
@@ -1,52 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- # This is an RVM Project .rvmrc file, used to automatically load the ruby
4
- # development environment upon cd'ing into the directory
5
-
6
- # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
7
- # Only full ruby name is supported here, for short names use:
8
- # echo "rvm use 1.9.3" > .rvmrc
9
- environment_id="ruby-1.9.3-p327@cequel-migrations-rails"
10
-
11
- # Uncomment the following lines if you want to verify rvm version per project
12
- # rvmrc_rvm_version="1.16.20 (master)" # 1.10.1 seams as a safe start
13
- # eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
14
- # echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
15
- # return 1
16
- # }
17
-
18
- # First we attempt to load the desired environment directly from the environment
19
- # file. This is very fast and efficient compared to running through the entire
20
- # CLI and selector. If you want feedback on which environment was used then
21
- # insert the word 'use' after --create as this triggers verbose mode.
22
- if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
23
- && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
24
- then
25
- \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
26
- [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
27
- \. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
28
- if [[ $- == *i* ]] # check for interactive shells
29
- then echo "Using: $(tput setaf 2)$GEM_HOME$(tput sgr0)" # show the user the ruby and gemset they are using in green
30
- else echo "Using: $GEM_HOME" # don't use colors in non-interactive shells
31
- fi
32
- else
33
- # If the environment file has not yet been created, use the RVM CLI to select.
34
- rvm --create use "$environment_id" || {
35
- echo "Failed to create RVM environment '${environment_id}'."
36
- return 1
37
- }
38
- fi
39
-
40
- # If you use bundler, this might be useful to you:
41
- # if [[ -s Gemfile ]] && {
42
- # ! builtin command -v bundle >/dev/null ||
43
- # builtin command -v bundle | GREP_OPTIONS= \grep $rvm_path/bin/bundle >/dev/null
44
- # }
45
- # then
46
- # printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
47
- # gem install bundler
48
- # fi
49
- # if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
50
- # then
51
- # bundle install | GREP_OPTIONS= \grep -vE '^Using|Your bundle is complete'
52
- # fi