Module: Swift::Migrations::ClassMethods

Included in:
Record
Defined in:
lib/swift/migrations.rb

Instance Method Summary collapse

Instance Method Details

#migrate!(db = Swift.db) ⇒ Object

Examples:

User.migrate!

Parameters:

See Also:



24
25
26
# File 'lib/swift/migrations.rb', line 24

def migrate! db = Swift.db
  db.migrate! self
end

#migrations(&migrations) ⇒ Object

Examples:

class User < Swift::Record
  migrations do |db|
    db.execute %q{create table users(id serial, name text, age int)}
  end
end

Parameters:

  • migrations (Proc)

See Also:



14
15
16
# File 'lib/swift/migrations.rb', line 14

def migrations &migrations
  define_singleton_method(:migrate!, lambda{|db = Swift.db| migrations.call(db)})
end