Hi, Is it possible to populate the development database from the test fixtures? I''m trying to keep the development database schema in a plain-text sql file and modifying that when I need to modify the database structure. However, then I have to either manually repopulate the database or add in additional sql statements that populate the test database. It seems like it would be useful to have a rake command that populates the development database based on what test fixtures you have. Thanks, Joe
Brian Buckley
2005-Jul-06 17:14 UTC
Re: populating development database from test fixtures
Joe, Add :fixtures_load_order to your environment.rb.and run this rake task, credit to Tim Bates and see the June 23 thread. --Brian desc "Load fixtures data into the development database" task :load_fixtures_data_to_development => :environment do require ''active_record/fixtures'' ActiveRecord::Base.establish_connection( ActiveRecord::Base.configurations["development"]) Fixtures.create_fixtures("test/fixtures", ActiveRecord::Base.configurations[:fixtures_load_order]) end On 7/6/05, Joe Van Dyk <joevandyk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > Is it possible to populate the development database from the test > fixtures? I''m trying to keep the development database schema in a > plain-text sql file and modifying that when I need to modify the > database structure. However, then I have to either manually > repopulate the database or add in additional sql statements that > populate the test database. > > It seems like it would be useful to have a rake command that populates > the development database based on what test fixtures you have. > > Thanks, > Joe > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
For some reason, this isn''t really working for me. Is :fixtures_load_order supposed to be an array of fixtures that would be loaded into the development database? On 7/6/05, Joe Van Dyk <joevandyk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Where do I add :fixtures_load_order in config/environment.rb? > > On 7/6/05, Brian Buckley <briankbuckley-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Joe, > > > > Add :fixtures_load_order to your environment.rb.and run this rake > > task, credit to Tim Bates and see the June 23 thread. > > > > --Brian > > > > desc "Load fixtures data into the development database" > > task :load_fixtures_data_to_development => :environment do > > require ''active_record/fixtures'' > > ActiveRecord::Base.establish_connection( > > ActiveRecord::Base.configurations["development"]) > > Fixtures.create_fixtures("test/fixtures", > > ActiveRecord::Base.configurations[:fixtures_load_order]) > > end > > > > > > On 7/6/05, Joe Van Dyk <joevandyk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi, > > > > > > Is it possible to populate the development database from the test > > > fixtures? I''m trying to keep the development database schema in a > > > plain-text sql file and modifying that when I need to modify the > > > database structure. However, then I have to either manually > > > repopulate the database or add in additional sql statements that > > > populate the test database. > > > > > > It seems like it would be useful to have a rake command that populates > > > the development database based on what test fixtures you have. > > > > > > Thanks, > > > Joe > > > _______________________________________________ > > > Rails mailing list > > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > >
Brian Buckley
2005-Jul-06 17:51 UTC
Re: populating development database from test fixtures
Joe, I added the line below at the very end of config/environment.rb. ActiveRecord::Base.configurations[:fixtures_load_order] ["firms","widgets","clients"] The array represents the order the tables must be loaded to avoid foreign key constraint violations. Put your own tables in. If loading order doesn''t matter for your situation then I think you can just delete the last line in that rake task instead of doing this. Brian