This is my first project with rails. I am following the book of Curt Hibbs and Bruce Tate. the book is called Ruby on rails: up and running. I built eight different models for eight tables using ruby script/generate model .... Then I went to db/migrate and introduced my columns for each *.rb file. When I do rake migrate only two tables get created on my persoal oracle database. Rest of them do not get created. I see schema.rb in db directory and I can only see 2 tables created. create_table "am_ba_departments", :force => true do |t| t.column "department_name", :string t.column "created_on", :datetime t.column "created_at", :time t.column "updated_on", :datetime t.column "updated_at", :time t.column "lock_version", :integer end create_table "am_software_categories", :force => true do |t| t.column "software_category", :string t.column "created_on", :datetime t.column "created_at", :time t.column "updated_on", :datetime t.column "updated_at", :time t.column "lock_version", :integer end Am I doing something wrong or is there a bug in rake. Any help would be appreciated. If needed I can provide more specific information. -- 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 -~----------~----~----~----~------~----~------~--~---
Did you run rake befor you were finished with your migrations ? This is easily done, and once rake has run a migration one it won''t (by itself) run those migrations again, even if you have changed them. The easiest thing to do is probably to blow away the contents of your database. Fred -- 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 -~----------~----~----~----~------~----~------~--~---
Rakesh Malhotra <rails-mailing-list@...> writes:> When I do rake migrate only two tables get created on my persoaloracle> database. Rest of them do not get created. I see schema.rb in db > directory and I can only see 2 tables created.Are these in one migration or multiple migrations? There were no error messages when you ran the Rake task? Run rake migrate --trace; that might give you a more detailed view of what''s going on. BTW, I always run my migrations inside a transaction, so either it all works or nothing gets saved: def self.up ActiveRecord::Base.transaction do .. migration stuff here end end --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Does ActiveRecord::Base.transaction support DDL transactions? I think most databases implicitly commit after any DDL statement. I dont think creating multiple tables in a transaction will be all or nothing. Ali On Oct 10, 6:02 pm, "kbob" <wrightwedd...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Rakesh Malhotra <rails-mailing-list@...> writes: > > When I do rake migrate only two tables get created on my persoal > oracle > > database. Rest of them do not get created. I see schema.rb in db > > directory and I can only see 2 tables created.Are these in one migration or multiple migrations? > > There were no error messages when you ran the Rake task? > > Run rake migrate --trace; that might give you a more detailed view of > what''s > going on. > > BTW, I always run my migrations inside a transaction, so either it all > works or > nothing gets saved: > def self.up > ActiveRecord::Base.transaction do > .. migration stuff here > end > end--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I believe Postgres and MS SQL Server support DDL transactions. MySQL and Oracle do not, not sure about the others. All of this is from memory from a discussion at RailsConf 2006. Apologies in advance if I''m mistaken. On Oct 10, 2006, at 8:27 PM, Ali wrote:> Does ActiveRecord::Base.transaction support DDL transactions? I think > most databases implicitly commit after any DDL statement. I dont > think > creating multiple tables in a transaction will be all or nothing. > > Ali > > On Oct 10, 6:02 pm, "kbob" <wrightwedd...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> Rakesh Malhotra <rails-mailing-list@...> writes: >>> When I do rake migrate only two tables get created on my persoal >> oracle >>> database. Rest of them do not get created. I see schema.rb in db >>> directory and I can only see 2 tables created.Are these in one >>> migration or multiple migrations? >> >> There were no error messages when you ran the Rake task? >> >> Run rake migrate --trace; that might give you a more detailed view of >> what''s >> going on. >> >> BTW, I always run my migrations inside a transaction, so either it >> all >> works or >> nothing gets saved: >> def self.up >> ActiveRecord::Base.transaction do >> .. migration stuff here >> end >> end > > > >-- -- Tom Mornini --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Tom Mornini wrote:> I believe Postgres and MS SQL Server support DDL transactions. > > MySQL and Oracle do not, not sure about the others. > > All of this is from memory from a discussion at RailsConf 2006. > > Apologies in advance if I''m mistaken. > > On Oct 10, 2006, at 8:27 PM, Ali wrote: > >>> oracle >>> BTW, I always run my migrations inside a transaction, so either it >> > > -- > -- Tom MorniniSQL Server definately supports DDL transactions and in 2005 even DLL triggers... -- 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 -~----------~----~----~----~------~----~------~--~---
Fred wrote:> Did you run rake befor you were finished with your migrations ? This is > easily done, and once rake has run a migration one it won''t (by itself) > run those migrations again, even if you have changed them. The easiest > thing to do is probably to blow away the contents of your database. > > FredHi Fred, I created all the migrations and then I gave the command rake migration. I also ran rake migrate --trace I get the following output C:\InstantRails\InstantRails\rails_apps\asset>rake migrate --trace (in C:/InstantRails/InstantRails/rails_apps/asset) ** Invoke migrate (first_time) ** Invoke db:migrate (first_time) ** Invoke environment (first_time) ** Execute environment ** Execute db:migrate ** Invoke db:schema:dump (first_time) ** Invoke environment ** Execute db:schema:dump ** Execute migrate I have 8 migration scripts but rake picks up only two of them. Few of my other migration scripts define many to many relation. For example I have two tables am_applications and am_developers. For these two tables, I have two scripts. The first 001_create_am_applications.rb is as follows class CreateAmApplications < ActiveRecord::Migration def self.up create_table :am_applications do |t| t.column :business_application_name, :string t.column :developed_by, :string t.column :maintained_by, :string t.column :exposed_on_openview, :string t.column :primary_contact, :string t.column :backup_contact, :string t.column :remarks, :string t.column :created_on, :datetime t.column :created_at, :datetime t.column :updated_on, :datetime t.column :updated_at, :datetime t.column :lock_version, :integer end end def self.down drop_table :am_applications end end The second one 003_create_am_developers.rb is as follows class CreateAmDevelopers < ActiveRecord::Migration def self.up create_table :am_developers do |t| t.column :name, :string t.column :software_expertise, :string t.column :application_expertise, :string t.column :other_expertise, :string t.column :remarks, :string t.column :created_on, :datetime t.column :created_at, :datetime t.column :updated_on, :datetime t.column :updated_at, :datetime t.column :lock_version, :integer end create_table("am_applications_am_developers", :id=>false) do |t| t.column "am_application_id", :integer t.column "am_developer_id", :integer end end def self.down drop_table :am_developers end end Note that I introduced the join table between application and developers in the same class as CreateAmdeveloepers. So when I do rake migrate the above two and other tables having same relationship do not get migrated. I was wondering if defining the migration scripts in above format is the cause or there is nothing wrong with the way migration scripts are created and there could be problems with rake? -- 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 -~----------~----~----~----~------~----~------~--~---