Database seeding

Hi All,

How are people typically seeding a database when doing a new install?

I would assume doing this with a Rake task but it could also be done with migrations. Fixtures could also do this be used to do this?

Thoughts comments?

Thanks, Serge

I'm using fixtures and `rake db:fixtures:load`.

Hi Serge --

I would assume doing this with a Rake task but it could also be done with migrations. Fixtures could also do this be used to do this?

I prefer to use fixtures over migrations for this. So, you create your fixtures with all your seed data, and then load them with:

rake db:fixtures:load

This approach is cool because it serves a dual purpose: it gives you a place to put your seed data, and gives you realistic test data for testing.

/Jeff

How do you distinguish between test, production, and development fixtures? I can't imagine that they're going to be the same.

OK, I can imagine that they're the same for production and development, but not test. Surely test is going to have a much richer (darker, perhaps - some test data should be designed to find problems) set of fixtures than you'd want in seed data.

- James Moore

Yeah, you don't. At least, there's no easy way to do it that I know of. I was more or less thinking about the kind of data that you 'keep' in your app, but that is often delegated to the database for easier maintenance. A good example is content for a help section..

You're right about test data in fixtures -- it should be realistic, not just ideal.

on the topic of fixtures and using them to seed the database:

i have this in my migrations to populate some of my tables that shouldn't be blank when my app gets deployed:

  cmd = 'rake db:fixtures:load FIXTURES=countries,provstates,employees'   system cmd   Employee.delete_all "username != 'admin'" #delete all but admin

the countries and provstates all have the real actual data that those tables should be seeded with.. the employees table however contains my test entries as well as the 'admin' account which needs to already be present to get into the app and setup more stuff when deploying the app.. the delete_all gets rid of the extra test entries.. Note: i have 'class Employee < ActiveRecord::Base; end #temporary activerecord class' at the top of my migrations file so i can use the Employee activerecord class in the migration.

hope this is helpful stuart

serge@sozonoff.com wrote:

How are people typically seeding a database when doing a new install?

I would assume doing this with a Rake task but it could also be done with migrations. Fixtures could also do this be used to do this?

I have the same question too. I have the feeling something is missing in Rails here. A standard way to fill your data with initial data would be really nice. Examples could be default users, country codes, holidays, ... Of course the fixtures way works but it feels strange to use fixtures, a concept of testing, to load your database. It's probably just a matter of coming up with a good name for a Rake task, but it's missing imho.

Bart

Hello,

I need to do authentication of my Rails application users against an existing RADIUS. I'm using the salted-login-generator as the base of my user-system and tried to get this working with RADIUSlib-0.5. But RADIUSlib seems to be very UNIX-specific and there's a lot of work of reimplementing to do, to get this up and running. I don't know, if radiusaaa is any better (in the meaning of "closer to windows") than RADIUSlib. Additionally the project-homepage seems to be empty (no downloadable files).

Are there any experiences with implementations of RADIUS-Clients on Windows? Any advice would be appreciated!

Regards

Horst