Re: Implement the schema.rb for updating the database

Colin Law
Sat, 20 Aug 2011 15:21:29 -0000

On 20 August 2011 15:53, coolesting
<coolesting-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:
> Hi, guys
>
> I fix the db/schema.rb file, and want to update the database using it .
> How i should do. i try ''rake db:migrate'' but it not
works.

You should not manually change schema.rb, you should instead write a
migration to change the database design.  Running the migration will
update schema.rb.

See the Rails Guide on Migrations for how to do this.

In order to put schema.rb back to what it should be before running the
migrations you can do
rake db:schema:dump
You can alternatively just revert schema.rb using your Version Control
System.  If you are not using a VCS then start doing so immediately,
you will not regret it.  I prefer git.

I assume you are just getting started with Rails so have a look at all
the Rails Guides and work through some tutorials.  Make sure you are
using Rails 3 and that the tutorial is for this version.
railstutorial.org is good and is free to use online.

Colin

Colin