Hello, I have write a schema.rb database such as this: ActiveRecord::Schema.define do create_table :arts do |t| t.string :name, :null => false, :limit => 45 end end This file is saved into test/db/schema.rb, and test/config/database.yml is correctly configured with "test_development" database created in a MySQL server. Could you help me to install the content of schema.rb file in MySQL and in my Rails 2 application? Thank you for your help. Regards -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
David B. wrote:> Hello, > > I have write a schema.rb database such as this: > > ActiveRecord::Schema.define do > create_table :arts do |t| > t.string :name, :null => false, :limit => 45 > end > end > > This file is saved into test/db/schema.rb, and test/config/database.yml > is correctly configured with "test_development" database created in a > MySQL server. >Well, this is a rather awkward way of doing things. Effectively, db/schema.rb is a composite migration file. To load it one would typically move it to something called similar to db/migrate/001_initial_db_load.rb and run rake db:migrate. When one runs the rake task, depending upon the settings in config/environment.rb, then db/schema.rb gets overwritten with the results of the applied migrations, making direct editing of this file rather pointless. It would be far better for you to read up on migrations and to use individual migrations contained in db/migrate instead. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
<...>> Well, this is a rather awkward way of doing things. Effectively, > db/schema.rb is a composite migration file. To load it one would > typically move it to something called similar to > db/migrate/001_initial_db_load.rb and run rake db:migrate.To load schema.rb. you do not need to move or rename anything, just use rake db:schema:load Regards, Rimantas -- http://rimantas.com/ --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Rimantas Liubertas wrote:> <...> >> Well, this is a rather awkward way of doing things. Effectively, >> db/schema.rb is a composite migration file. To load it one would >> typically move it to something called similar to >> db/migrate/001_initial_db_load.rb and run rake db:migrate. > > To load schema.rb. you do not need to move or rename anything, > just use rake db:schema:load > > Regards, > Rimantas > -- > http://rimantas.com/Wow! This command work perfectly, thanks a lot! :) -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
By the way, I just have a last question: is there a command to automaticly create all the model for any tables of my database? I ask this because my database have 16 tables and I don''t think using "script/generate model <a table>" 16 times is a good idea. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Mon, May 12, 2008 at 8:26 AM, David B. <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > By the way, I just have a last question: is there a command to > automaticly create all the model for any tables of my database? I ask > this because my database have 16 tables and I don''t think using > "script/generate model <a table>" 16 times is a good idea.for x in `echo "show tables" | mysql my_db`; do script/generate model $x; done -- Greg Donald http://destiney.com/ --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Mon, May 12, 2008 at 11:29 PM, Greg Donald <gdonald-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> for x in `echo "show tables" | mysql my_db`; do script/generate model $x; doneOops, I forgot to remove the ''s'' from the table name, model names usually being singular and all: for x in `echo "show tables" | mysql my_db | sed ''s/s$//''`; do script/generate model $x; done -- Greg Donald http://destiney.com/ --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
That should work well as long as you don''t have a singular/plural pair that doesn''t use "+s" for the plural (e.g., pony, ponies). You could probably route your command through pluralize, but in that case, it would be easier just to type in the 16 commands. :) -Kyle On May 12, 11:40 pm, "Greg Donald" <gdon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Mon, May 12, 2008 at 11:29 PM, Greg Donald <gdon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > for x in `echo "show tables" | mysql my_db`; do script/generate model $x; done > > Oops, I forgot to remove the ''s'' from the table name, model names > usually being singular and all: > > for x in `echo "show tables" | mysql my_db | sed ''s/s$//''`; do > script/generate model $x; done > > -- > Greg Donaldhttp://destiney.com/--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks :) -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---