class CassandraStore::Migration
Public Class Methods
down(path, version)
click to toggle source
# File lib/cassandra_store/migration.rb, line 18 def self.down(path, version) migration_class(path, version).new.down CassandraStore::SchemaMigration.where(version: version.to_s).delete_all end
migrate(path)
click to toggle source
# File lib/cassandra_store/migration.rb, line 24 def self.migrate(path) migrated = CassandraStore::SchemaMigration.all.to_a.map(&:version).to_set all = Dir[File.join(path, "*.rb")].map { |file| File.basename(file) } todo = all.select { |file| file =~ /\A[0-9]+_/ && !migrated.include?(file.to_i.to_s) }.sort_by(&:to_i) todo.each do |file| up path, file.to_i.to_s end end
migration_class(path, version)
click to toggle source
# File lib/cassandra_store/migration.rb, line 6 def self.migration_class(path, version) require migration_file(path, version) File.basename(migration_file(path, version), ".rb").gsub(/\A[0-9]+_/, "").camelcase.constantize end
migration_file(path, version)
click to toggle source
# File lib/cassandra_store/migration.rb, line 2 def self.migration_file(path, version) Dir[File.join(path, "#{version}_*.rb")].first end
up(path, version)
click to toggle source
# File lib/cassandra_store/migration.rb, line 12 def self.up(path, version) migration_class(path, version).new.up CassandraStore::SchemaMigration.create!(version: version.to_s) end
Public Instance Methods
down()
click to toggle source
# File lib/cassandra_store/migration.rb, line 40 def down; end
execute(*args)
click to toggle source
# File lib/cassandra_store/migration.rb, line 34 def execute(*args) CassandraStore::Base.execute(*args) end
up()
click to toggle source
# File lib/cassandra_store/migration.rb, line 38 def up; end