Re: Implement the schema.rb for updating the database

Colin Law
Sun, 21 Aug 2011 07:22:42 -0000

On 21 August 2011 03:23, coolesting
<coolesting-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:
> But i still have a question, can i design a database schema for migrating
> once time. I don''t want gonna to create a migration file for some
operation
> to database again and again.
> Just creating a schema file for initializing the database at first.

I don''t see why you want to write a schema manually rather than just
writing the first migration manually.  It is just as easy to write the
inital migration as an initial schema.  In fact the syntax is almost
identical.  However, if you do want to do that then you can use rake
db:create to create the db from the schema.  Note that this is not the
question you asked originally, which was how to update the db from an
updated schema.  rake db:create creates a new database rather than
modifying an existing one.  A migration will modify an existing data
without destroying existing data.

Colin