Question

I like Rails, but I'm not a big fan of migrations.

How can I use the ActiveRecord::Scema tool to create a database without using SQL and without migrations?

I know you use it like this:

ActiveRecord::Schema.define do
    create_table :authors do |t|
        t.string :name, :null => false
    end

    add_index :authors, :name, :unique

    create_table :posts do |t|
        t.integer :author_id, :null => false
        t.string :subject
        t.text :body
        t.boolean :private, :default => false
    end

    add_index :posts, :author_id
end

But how do you run this?

Please don't recommend to use migrations, because I... simply don't like them.

Was it helpful?

Solution

Well migrations are the best way to manage the evolutions of your database ;)

However you can directly load a schema.rb into your database if you wish to.

rake db:schema:load

I wouldn't recomment it however.

OTHER TIPS

try rake db:schema:load

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top