DAddYE/mini_record — pull request #12 by activestylus (2012-01-05 16:06:03+00:00)
Title: Auto generate columns for AR associations

Stealing a bit from Datamapper, I've managed to get this working (specs were also added)

```ruby
class Dog < ActiveRecord::Base
belongs_to :owner
end
Dog.auto_upgrade!
```

will create an :owner_id integer field and index it as well

```ruby
class Dog < ActiveRecord::Base
belongs_to :doggable, :polymorphic => true
end
Dog.auto_upgrade!
```

will create doggable_id:integer and doggable_type:string fields along with combined index (:dogs, [:doggable_id, :doggable_type])

```ruby
class Dog < ActiveRecord::Base
has_and_belongs_to_many :owners
end
Dog.auto_upgrade!
```

Will create the join table and index all the id columns.

## Backwards Compatibility
This should not break any existing models as it performs a check on the db to see if the columns/indexes exist. You should be able to happily drop it in your app with no issues. Hope you enjoy it as much as I've enjoyed using this gem - keep up the great work