Perfect. Thanks Vais and Jeremy. On Wed, May 20, 2009 at 8:00 AM, Jeremy Evans <[email protected]>wrote:
> > On May 20, 6:53 am, Scott LaBounty <[email protected]> wrote: > > Is there a way to add data to a table using migrations? In other words if > I > > have a table with a columns for say "name" and "age", I'd like to fill in > a > > couple of rows with "John Smith, 22" and "Jane Doe, 33". It seems like > I've > > seen someone do this here on the list but can't find it now. > > What Vais said is true. However, make sure you use only datasets in > your migration, not models. For example: > > Class.new(Sequel::Migration) do > def up > create_table(:table){...} > from(:table).insert(:name=>'John', :age=>22) > ... > end > end > > The migration uses method_missing to proxy to the Database object that > calls it, so the from line is just like: > > DB.from(:table).insert(:name=>'John', :age=>22) > > Jeremy > > > -- Scott http://steamcode.blogspot.com/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sequel-talk" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/sequel-talk?hl=en -~----------~----~----~----~------~----~------~--~---
