Apologies if this is blatantly obvious and I am wasting your time - I''m quite an infrequent Rails contributor... Basically I am looking for an easy way to load the schema definitions from activerecord/test/schema into my databases. In the RUNNING_UNIT_TESTS file it says "When you have the database online, you can import the fixture tables with the test/schema/*.sql files." This seems to be outdated as all the files in test/schema are now .rb schema files. I can''t see a rake task to perform this - maybe there should be one? I''d be happy to create a patch to make this a bit easier for others in the future. Cheers, Jon --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
On Sun, Sep 7, 2008 at 2:58 PM, Jon Leighton <j@jonathanleighton.com> wrote:> > Apologies if this is blatantly obvious and I am wasting your time - > I''m quite an infrequent Rails contributor... > > Basically I am looking for an easy way to load the schema definitions > from activerecord/test/schema into my databases. In the > RUNNING_UNIT_TESTS file it says "When you have the database online, > you can import the fixture tables with the test/schema/*.sql files." > This seems to be outdated as all the files in test/schema are now .rb > schema files. > > I can''t see a rake task to perform this - maybe there should be one?There are a few: rake build_frontbase_databases # Build the FrontBase test databases rake build_mysql_databases # Build the MySQL test databases rake build_postgresql_databases # Build the PostgreSQL test databases rake drop_mysql_databases # Drop the MySQL test databases rake drop_postgresql_databases # Drop the PostgreSQL test databases rake rebuild_frontbase_databases # Rebuild the FrontBase test databases rake rebuild_mysql_databases # Rebuild the MySQL test databases rake rebuild_postgresql_databases # Rebuild the PostgreSQL test databases I guess the advice in that file should be updated to reflect the rake tasks we have now.> I''d be happy to create a patch to make this a bit easier for others in > the future. > > Cheers, > Jon > > > >-- Cheers Koz --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
On Sep 7, 2008, at 5:58 AM, Jon Leighton wrote:> > Apologies if this is blatantly obvious and I am wasting your time - > I''m quite an infrequent Rails contributor... > > Basically I am looking for an easy way to load the schema definitions > from activerecord/test/schema into my databases. In the > RUNNING_UNIT_TESTS file it says "When you have the database online, > you can import the fixture tables with the test/schema/*.sql files." > This seems to be outdated as all the files in test/schema are now .rb > schema files. > > I can''t see a rake task to perform this - maybe there should be one? > > I''d be happy to create a patch to make this a bit easier for others in > the future.If you run the whole test suite via rake test_mysql, it happens automatically using a dirty trick. If you want to do it manually, you need to run the file aaa_create_tables_test.rb - the ''aaa'' forces the file to run before all the other tests, ensuring the schema is loaded. In directory rails/activerecord: $ ruby -Ilib:test:test/connections/native_mysql test/cases/ aaa_create_tables_test.rb Using native MySQL Loaded suite test/cases/aaa_create_tables_test Started .-- adapter_name() -> 0.0000s -- create_table(:accounts, {:force=>true}) -> 0.0076s # lots of lines omitted... -- create_table(:binary_fields, {:options=>"CHARACTER SET latin1", :force=>true}) -> 0.0074s . Finished in 1.067615 seconds. 2 tests, 2 assertions, 0 failures, 0 errors If you use some other db than mysql, just change the -I option to use the correct connection file. RUNNING_UNIT_TESTS needs updating. I was going to do that at one point but got distracted. If you have time to do a doc patch, I''ll +1 it :-) -- Josh Susser http://blog.hasmanythrough.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
On Sep 7, 10:53 pm, Josh Susser <j...@hasmanythrough.com> wrote:> On Sep 7, 2008, at 5:58 AM, Jon Leighton wrote: > If you run the whole test suite via rake test_mysql, it happens > automatically using a dirty trick. If you want to do it manually, you > need to run the file aaa_create_tables_test.rb - the ''aaa'' forces the > file to run before all the other tests, ensuring the schema is loaded.Thanks. I will certainly create a doc patch for RUNNING_UNIT_TESTS, but what do people thing about doing away with the aaa_create_table_test.rb file? Instead we could check for the existence of one of the table we need in helper.rb, and if it''s not there we could load the schema. This would enable the schema to be autoloaded even when running single test files. Jon --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Jon Leighton wrote:> On Sep 7, 10:53 pm, Josh Susser <j...@hasmanythrough.com> wrote: >> On Sep 7, 2008, at 5:58 AM, Jon Leighton wrote: >> If you run the whole test suite via rake test_mysql, it happens >> automatically using a dirty trick. If you want to do it manually, you >> need to run the file aaa_create_tables_test.rb - the ''aaa'' forces the >> file to run before all the other tests, ensuring the schema is loaded. > > Thanks. > > I will certainly create a doc patch for RUNNING_UNIT_TESTS, but what > do people thing about doing away with the aaa_create_table_test.rb > file? Instead we could check for the existence of one of the table we > need in helper.rb, and if it''s not there we could load the schema. > This would enable the schema to be autoloaded even when running single > test files.If you can figure out a nice solution that supports this that would be fantastic. The only catch I can see to the test helper approach is that you could be repeatedly testing for the existence or otherwise of those tables. It''s hardly likely to be a performance issue, but it''s a little messy all the same. If you need any help tidying this up, just let us know. -- Cheers, Koz --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---