Jeremy, So I should probably stick with "String" then?
Scott On Wed, Jul 29, 2009 at 8:04 AM, Jeremy Evans <[email protected]>wrote: > > On Jul 29, 6:11 am, Scott LaBounty <[email protected]> wrote: > > I'm trying to do a migration to add a new text column to a table. This > > doesn't work: > > > > def up > > alter_table(:books) do > > add_column :description, Text > > end > > end > > > > but this does: > > > > def up > > alter_table(:books) do > > add_column :description, String > > end > > end > > > > I've actually used "Text" in creating tables, just not in an add_column. > Is > > there some reason this won't work? > > Text is not a valid ruby constant, String is. The generic type > conversion layer takes some standard ruby classes and converts them to > database specific types. As ruby has no class named Text, you are > probably getting a NameError. Note that you can use :text instead of > Text and it will work fine (on SQLite). The advantage of using ruby > classes is that your migrations are more database independent. For > example, if you use TrueClass on PostgreSQL, you'll get the boolean > type, but on MySQL, you'll get the tinyint(1) type (since MySQL > doesn't have a boolean type). > > 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 -~----------~----~----~----~------~----~------~--~---
