views:

18

answers:

2

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.

+1  A: 

try rake db:schema:load

stephenmurdoch
alternatively, if you don't like migrations, try some **NOSQL** based ORM's like mongoid - there's a great tutorial [here](http://wiki.github.com/fortuity/rails3-mongoid-devise/tutorial-walkthrough)
stephenmurdoch
+2  A: 

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.

Damien MATHIEU
And what kind of file do I need to create?
Alex
This command uses the file `db/schema.rb` which is automatically generated by your migrations (when using them).
Damien MATHIEU