Skip to content

Commit

Permalink
schema migrations work as instances
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Nov 17, 2010
1 parent 8b2f801 commit 0bea9fd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
11 changes: 7 additions & 4 deletions activerecord/lib/active_record/migration.rb
Expand Up @@ -288,12 +288,15 @@ def initialize(name)
#
class Migration
class << self
attr_accessor :verbose
attr_accessor :delegate # :nodoc:
def method_missing(name, *args, &block) # :nodoc:
(delegate || superclass.delegate).send(name, *args, &block)
end
end

def self.method_missing(name, *args, &block) # :nodoc:
(delegate || superclass.delegate).send(name, *args, &block)
end

cattr_accessor :verbose

self.delegate = new
self.verbose = true

Expand Down
5 changes: 3 additions & 2 deletions activerecord/lib/active_record/schema.rb
Expand Up @@ -46,11 +46,12 @@ def migrations_path
# ...
# end
def self.define(info={}, &block)
new.instance_eval(&block)
schema = new
schema.instance_eval(&block)

unless info[:version].blank?
initialize_schema_migrations_table
assume_migrated_upto_version(info[:version], migrations_path)
assume_migrated_upto_version(info[:version], schema.migrations_path)
end
end
end
Expand Down
1 change: 1 addition & 0 deletions activerecord/test/cases/migration_test.rb
Expand Up @@ -19,6 +19,7 @@ class ActiveRecord::Migration
class <<self
attr_accessor :message_count
end

def puts(text="")
self.class.message_count ||= 0
self.class.message_count += 1
Expand Down

0 comments on commit 0bea9fd

Please sign in to comment.