I'm suuuuper lazy and don't like making migrations. I want to make models I'm going to use anyway and have something else figure out the migrations for me in ruby because .Net has spoiled me. Is there a gem that will give me active record migrations from models? Can that even be possible since you never explicitly set types in ruby?
You can use DataMapper instead of ActiveRecord.
Sample Code from the DataMapper Documentation:
require 'rubygems'
require 'dm-core'
require 'dm-migrations'
DataMapper::Logger.new($stdout, :debug)
DataMapper.setup(:default, 'mysql://localhost/test')
class Person
include DataMapper::Resource
property :id, Serial
property :name, String, :required => true
end
DataMapper.auto_migrate!
This doesn't make any sense. Your models pull data their structure from the schema, they don't contain column/table definitions. There is no way to "push" table structure from your models into migrations, it's impossible. The data just isn't there.
This model, as written, may have persist to a table with a thousand columns or one column, there is no way of knowing:
class User < ActiveRecord::Base
end
Just use the Rails generators to produce your models and migrations at the same time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With