Topic: Migrations and Data Types
I'm very new to Rails and am just beginning my first attempt at a rails application. Initially I tried to cobble something together by following the tutorial on ONLamp.com, the tutorial worked fine; but when I tried to introduce my own tables I kept getting 'nil object' errors.
Most of the advice I could find indicated problems with foreign keys, so rather than create my tables & keys manually I decided to use Rails migrations to handle it all for me.
Now I've just written a migration script and used rake to do the migration - all worked fine. My question is: Where can I find a list of the supported data types (object types?) I can use in my migration script?
Here's my migration code:
class Myvalues < ActiveRecord::Migration
create_table "myvalues" do |t|
t.column "description", :string
Pretty simple, huh?
However this produces a varchar(255) in my MySQL database and all I really wanted was a varchar(50).
I will also want to provide MySQL text fields, floats, dates, times, enums etc. Can these be done using migrations?
Is there any way to specify default values and turn on / off NULLS?