Skip to content

Commit

Permalink
Fix the problem that was preventing rows from taking updates.
Browse files Browse the repository at this point in the history
As a consequence, I removed the ability to configure which column to use for the schema version. It's
currently YAGNI.
  • Loading branch information
ryanking committed Nov 12, 2009
1 parent c176e30 commit fccf3bf
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
6 changes: 2 additions & 4 deletions lib/cassandra_object/migrations.rb
Expand Up @@ -2,8 +2,6 @@ module CassandraObject
module Migrations
extend ActiveSupport::Concern
included do
cattr_accessor :migration_column_name
self.migration_column_name = :schema_version
class_inheritable_array :migrations
class_inheritable_accessor :current_schema_version
self.current_schema_version = 0
Expand Down Expand Up @@ -43,8 +41,8 @@ def migrate(version, &blk)
end

def instantiate(key, attributes)
version = attributes.delete('schema_version')
original_attributes = attributes.dup
version = attributes[migration_column_name.to_s]
if version == current_schema_version
return super(key, attributes)
end
Expand All @@ -61,7 +59,7 @@ def instantiate(key, attributes)

migrations_to_run.inject(attributes) do |attrs, migration|
migration.run(attrs)
attrs[migration_column_name.to_s] = migration.version.to_s
@schema_version = migration.version.to_s
attrs
end

Expand Down
8 changes: 8 additions & 0 deletions test/basic_scenarios_test.rb
Expand Up @@ -167,4 +167,12 @@ class JankyObject < CassandraObject::Base
end
end
end

test "updating columns" do
appt = Appointment.new(:start_time => Time.now, :title => 'emergency meeting')
appt.save!
appt = Appointment.get(appt.key)
appt.start_time = Time.now + 1.hour
appt.save!
end
end
2 changes: 0 additions & 2 deletions test/fixture_models.rb
Expand Up @@ -20,8 +20,6 @@ def should_be_cool
errors.add(:first_name, "must be that of a cool person")
end
end


end

class Invoice < CassandraObject::Base
Expand Down

0 comments on commit fccf3bf

Please sign in to comment.