cassie 1.0.3 → 1.0.4

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: 57931ab0cf0675f1ee2165b8856356f273475769
4
- data.tar.gz: faa9b5db7b96dc383d7042a979e5019967868f6d
3
+ metadata.gz: ae2e69dcfacf0f63a197eeb55e733d089fef8f7f
4
+ data.tar.gz: 5f7d24cd9dd32370c65f4a94a8d37aa4954782bf
5
5
  SHA512:
6
- metadata.gz: 251c1ec5bfd7014dd95b3914968a1921aaafdb3cc8f2057b42e7deafebe686af55c664ef9719e51c4f166acbce27ac7a0e95cdaa829cca9f2d772d1ec547aea5
7
- data.tar.gz: c8c92da0e5de488a37014eadd48920723e7d1a3e4c1138276620a81c4f90b974c996c5398d167a547d18ac2b3b337b9cf6043fbbdb6692c130d639f9a56aa7a7
6
+ metadata.gz: 7add13ef36796deebe1fbccf41a0540e8b7f961f344257bdb59b57b8698cd16a20b4485047ced5a7d0bbb86c3e4cf22f458ade9db86f2999e4ddc3b8cf12c3fb
7
+ data.tar.gz: 9ee9fc8144b862ab2edff0bc5adb547a15bdb2385c030f0b89d0a29d93b5b7bd15ba335fa8e4800323d815aa88c6eb5ae22af41af4cdc00ce50457fb0753b3e0
@@ -44,6 +44,10 @@ Import your existing `cassandra_migrations` migration files with a single task:
44
44
  cassie migrations:import
45
45
  ```
46
46
  ```bash
47
+ -- Initializing Cassie Versioning
48
+ -- done
49
+ -- Initializing 'cassie_development' Keyspace
50
+ -- done
47
51
  -- Importing `cassandra_migrations` migration files
48
52
  - Importing db/cassandra_migrate/20161206214301_initial_database.rb
49
53
  > created /db/cassandra/migrations/0000_0000_0000_0001_initial_database.rb
@@ -58,6 +62,10 @@ cassie migrations:import
58
62
  > recorded version 0.0.2.0
59
63
  - done
60
64
  -- done
65
+ -- Dumping Cassandra schema (version 0.0.0.1)
66
+ - Writing to db/cassandra/schema.cql
67
+ - done
68
+ -- done
61
69
  ```
62
70
 
63
71
  > The original `cassandra_migrations` migration files and schema in the physical layer are not changed. Remove the old files when comfortable.
@@ -11,15 +11,18 @@ module Cassie::Schema
11
11
  attr_accessor :final_version
12
12
  # The migration files to be imported
13
13
  attr_accessor :migration_files
14
+ # The newly imported Cassie migration files
15
+ attr_accessor :imported_paths
14
16
  # A callback fired before importing each migration
15
17
  attr_accessor :before_each
16
18
  # A callback fired after importing each migration
17
19
  attr_accessor :after_each
18
20
 
19
21
  def initialize(source_path=nil)
20
- @source = source_path || default_source_path
21
- @final_version = Cassie::Schema::Version.new("0.0.1.0", "Remove cassandra_migrations schema")
22
- @migration_files = find_migration_files
22
+ @source = source_path || default_source_path
23
+ @final_version = Cassie::Schema::Version.new("0.0.1.0", "Remove cassandra_migrations schema")
24
+ @migration_files = find_migration_files
25
+ @imported_paths = []
23
26
  @before_each = Proc.new{}
24
27
  @after_each = Proc.new{}
25
28
  end
@@ -27,7 +30,6 @@ module Cassie::Schema
27
30
  def import
28
31
  new_version = initial_version
29
32
  new_version.executor = "cassandra_migrations"
30
- new_version.executed_at = Time.now
31
33
 
32
34
  migration_files.each do |old_migration_file|
33
35
  before_each.call(old_migration_file)
@@ -39,7 +41,7 @@ module Cassie::Schema
39
41
  # that is built from the old file
40
42
  writer.migration_contents = old_migration_file.build_migration_class(new_version)
41
43
 
42
- writer.write
44
+ self.imported_paths << writer.write
43
45
 
44
46
  Cassie::Schema.record_version(new_version, false)
45
47
  after_each.call(new_version)
@@ -12,7 +12,7 @@ module Cassie::Schema
12
12
  # @!visibility private
13
13
  def self.extended(extender)
14
14
  extender.paths["schema_file"] = "db/cassandra/schema.cql"
15
- extender.paths["migrations_directory"] = "db/cassandra/migrations"
15
+ extender.paths[:migrations_directory] = "db/cassandra/migrations"
16
16
  extender.schema_keyspace = "cassie_schema"
17
17
  extender.versions_table = "versions"
18
18
  end
@@ -11,12 +11,16 @@ module Cassie::Schema
11
11
  set :number
12
12
  set :description
13
13
  set :executor
14
- set :executed_at
14
+ set :executed_at, if: :executed_at?
15
15
 
16
16
  map_from :version
17
17
 
18
18
  def bucket
19
19
  0
20
20
  end
21
+
22
+ def executed_at?
23
+ !executed_at.nil?
24
+ end
21
25
  end
22
26
  end
@@ -17,6 +17,11 @@ module Cassie::Schema
17
17
  ensure_dir_exist
18
18
  end
19
19
 
20
+ # Writes the version's migration clas code to a new
21
+ # ruby migraton file in the
22
+ # +Cassie::Schema.paths[:migrations_directory]+
23
+ # @return [String] the filename of the path written
24
+ # @raise [IOError] if a file with a matching version already exists
20
25
  def write
21
26
  with_io do |io|
22
27
  io << migration_contents
@@ -33,6 +38,7 @@ module Cassie::Schema
33
38
  # for the methods will come from that file
34
39
  # instead of (eval)
35
40
  load File.absolute_path(filename)
41
+ filename
36
42
  end
37
43
  end
38
44
 
@@ -50,7 +56,7 @@ module Cassie::Schema
50
56
  end
51
57
 
52
58
  def directory
53
- Cassie::Schema.paths["migrations_directory"]
59
+ Cassie::Schema.paths[:migrations_directory]
54
60
  end
55
61
 
56
62
  def basename
@@ -56,10 +56,11 @@ module Cassie::Schema
56
56
 
57
57
  InsertVersionQuery.new(version: version).execute!
58
58
  @applied_versions = nil
59
- rescue StandardError
59
+ rescue StandardError => e
60
60
  version.id = nil
61
61
  version.executed_at = nil
62
62
  version.executor = nil
63
+ raise e
63
64
  end
64
65
 
65
66
  # Remove the version from the schema version store.
@@ -74,7 +75,7 @@ module Cassie::Schema
74
75
  # Absolute paths to the migration files in the migration directory
75
76
  # @return [Array<String>]
76
77
  def migration_files
77
- Dir[root.join(paths["migrations_directory"], "[0-9]*_*.rb")]
78
+ Dir[root.join(paths[:migrations_directory], "[0-9]*_*.rb")]
78
79
  end
79
80
 
80
81
  # Versions for the {#migration_files}
@@ -4,7 +4,7 @@ require 'cassie/schema/cassandra_migrations/importer'
4
4
  namespace :cassie do
5
5
  namespace :migrations do
6
6
  desc "Imports existing `cassandra_migrations` migration files and converts to semantic versioning"
7
- task :import do
7
+ task :import => "cassie:schema:init" do
8
8
  include Cassie::Tasks::IO
9
9
 
10
10
  begin
@@ -31,9 +31,14 @@ namespace :cassie do
31
31
  importer.import
32
32
  puts "-- done"
33
33
  rescue => e
34
+ importer.imported_paths.each {|f| File.delete(f) }
34
35
  puts red("Error:\n #{e.message}")
35
36
  abort
36
37
  end
37
38
  end
38
39
  end
40
+ end
41
+
42
+ Rake::Task["cassie:migrations:import"].enhance do
43
+ Rake::Task["cassie:schema:dump"].invoke
39
44
  end
@@ -14,5 +14,8 @@ namespace :cassie do
14
14
  abort
15
15
  end
16
16
  end
17
+
18
+ desc "Print the history of applied schema migrations"
19
+ task :versions => :history
17
20
  end
18
21
  end
@@ -25,7 +25,6 @@ namespace :cassie do
25
25
  desc "Initialize the keyspace for the current environment"
26
26
  task :init_keyspace do
27
27
  include Cassie::Tasks::IO
28
- Cassie.keyspace = nil
29
28
 
30
29
  begin
31
30
  name = Cassie.configuration[:keyspace]
@@ -14,8 +14,12 @@ module Cassie::Tasks
14
14
  current_version = Cassie::Schema.version
15
15
 
16
16
  versions.each.with_index do |v|
17
- row = v.to_h.values_at(*members)
17
+ row = []
18
+ row[0] = v.number
18
19
  row[0] = "* #{row[0]}" if v == current_version
20
+ row[1] = v.description
21
+ row[2] = v.executor
22
+ row[3] ||= "Unknown"
19
23
  table.add_row(row)
20
24
  end
21
25
 
@@ -26,7 +30,6 @@ module Cassie::Tasks
26
30
  def print_statuses(versions)
27
31
  # Note: if we end up using this elsewhere, move to Version::VersionList
28
32
  # or something simliar, and have version collection methods return that
29
- members = [:number, :description]
30
33
  titles = ['Number', 'Description', 'Status', 'Migration File']
31
34
  table = Terminal::Table.new(headings: titles)
32
35
  current_version = Cassie::Schema.version
@@ -1,3 +1,3 @@
1
1
  module Cassie
2
- VERSION = "1.0.3"
2
+ VERSION = "1.0.4"
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.0.3
4
+ version: 1.0.4
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-13 00:00:00.000000000 Z
11
+ date: 2017-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cassandra-driver
@@ -92,10 +92,9 @@ dependencies:
92
92
  - - "~>"
93
93
  - !ruby/object:Gem::Version
94
94
  version: '1.10'
95
- description: Cassie provides database configration, versioned migrations, efficient
96
- session management, and query classes. This allows applications to use the functionality
97
- provided by the official `cassandra-driver` through lightweight and easy to use
98
- interfaces.
95
+ description: Application support for Apache Cassandra using the the official `cassandra-driver`.
96
+ Cassie provides cluster configration, versioned migrations, efficient session management,
97
+ and a class-based query DSL. Easy to use with lightweight, component-style interfaces.
99
98
  email: evan.prothro@gmail.com
100
99
  executables:
101
100
  - cassie
@@ -269,7 +268,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
269
268
  version: '0'
270
269
  requirements: []
271
270
  rubyforge_project:
272
- rubygems_version: 2.5.2
271
+ rubygems_version: 2.4.5.2
273
272
  signing_key:
274
273
  specification_version: 4
275
274
  summary: Apache Cassandra application support