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. thanks for helps. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thanks colin, the tutorail is very helpful to me. 2011/8/20 Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>> 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 > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.