Forum: Ruby on Rails fixtures for inititializing db

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
benanderson.us (Guest)
on 2005-11-19 22:37
(Received via mailing list)
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
petermichaux (Guest)
on 2005-11-20 00:05
(Received via mailing list)
Without db tables defined how would you identify sql column types from a
fixture file?

-Peter
Nshbrown N. (Guest)
on 2005-11-20 00:19
(Received via mailing list)
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
jeremy (Guest)
on 2005-11-20 00:50
(Received via mailing list)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Nov 19, 2005, at 2:05 PM, Peter M. 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-----
benanderson.us (Guest)
on 2005-11-21 13:29
(Received via mailing list)
Thanks Nathan - yeah that is what I was looking for.  Seems to be
working great.
This topic is locked and can not be replied to.