Hi, Is there a quick and dirty way to use fixtures inside of migrations? I''d like to be able to blow away my db and recreate it, with some predefined values. I know i can use a db export/import, but it looks like fixtures would be a good fit here. I tried doing this to my migrations: added: require File.dirname(__FILE__) + ''/../test_helper'' class AddANewTable < ActiveRecord::Migration def self.up ... fixtures :articles end ... but it doesn''t seem to be performing correctly. Is anyone usign this approach? Is there a best way to do it? Thanks, Ben
Without db tables defined how would you identify sql column types from a fixture file? -Peter _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Hey Ben, Haven''t toyed with it much, but I seen a rake task for this: [root@inimit rails]# rake -T ... rake load_fixtures # Load fixtures into the current environment''s database ... HTH. Warmest regards, Nathan. -------------------------------------------------------------- Nathaniel S. H. Brown Toll Free 1.877.4.INIMIT Inimit Innovations Phone 604.724.6624 www.inimit.com Fax 604.444.9942> -----Original Message----- > From: rails-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > [mailto:rails-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Ben Anderson > Sent: November 19, 2005 12:37 PM > To: rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > Subject: [Rails] fixtures for inititializing db > > Hi, > Is there a quick and dirty way to use fixtures inside of migrations? > I''d like to be able to blow away my db and recreate it, with > some predefined values. I know i can use a db export/import, > but it looks like fixtures would be a good fit here. I tried > doing this to my > migrations: > > added: > require File.dirname(__FILE__) + ''/../test_helper'' > > class AddANewTable < ActiveRecord::Migration > def self.up > ... > fixtures :articles > end > ... > > but it doesn''t seem to be performing correctly. Is anyone > usign this approach? Is there a best way to do it? > Thanks, > Ben > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Nov 19, 2005, at 2:05 PM, Peter Michaux wrote:> Without db tables defined how would you identify sql column types > from a fixture file?Types are inferred since they are (mostly) unambiguous. Databases'' treatment of boolean is a sore spot, however: true/false, ''t''/''f'', 1/0, etc etc. jeremy -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (Darwin) iD8DBQFDf6soAQHALep9HFYRAvIXAJ0WBtZNFHHWL3I3sDD5hPUkQPkM4wCg2Eeq 5a3Rncqq3SKMevTmLiWdvws=w7bW -----END PGP SIGNATURE-----
Thanks Nathan - yeah that is what I was looking for. Seems to be working great. On 11/19/05, Nathaniel S. H. Brown <nshb-wgYSSEAWXinQT0dZR+AlfA@public.gmane.org> wrote:> Hey Ben, > > Haven''t toyed with it much, but I seen a rake task for this: > > [root@inimit rails]# rake -T > ... > rake load_fixtures # Load fixtures into the current > environment''s database > ... > > HTH. > > Warmest regards, > Nathan. > > -------------------------------------------------------------- > Nathaniel S. H. Brown Toll Free 1.877.4.INIMIT > Inimit Innovations Phone 604.724.6624 > www.inimit.com Fax 604.444.9942 > > > > -----Original Message----- > > From: rails-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > [mailto:rails-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Ben Anderson > > Sent: November 19, 2005 12:37 PM > > To: rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > Subject: [Rails] fixtures for inititializing db > > > > Hi, > > Is there a quick and dirty way to use fixtures inside of migrations? > > I''d like to be able to blow away my db and recreate it, with > > some predefined values. I know i can use a db export/import, > > but it looks like fixtures would be a good fit here. I tried > > doing this to my > > migrations: > > > > added: > > require File.dirname(__FILE__) + ''/../test_helper'' > > > > class AddANewTable < ActiveRecord::Migration > > def self.up > > ... > > fixtures :articles > > end > > ... > > > > but it doesn''t seem to be performing correctly. Is anyone > > usign this approach? Is there a best way to do it? > > Thanks, > > Ben > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >