How do I describe an enumeration column in a Rails 3 migration?

前端 未结 11 1640
误落风尘
误落风尘 2020-12-24 04:23

How do I describe an enumeration column in a Rails 3 migration?

11条回答
  •  渐次进展
    2020-12-24 05:25

    In a Rails 3 Migration you can do the following:

    class CreateFoo < ActiveRecord::Migration
      def change
        create_table :foo do |t|
          t.column :foobar, "ENUM('foo', 'bar')"
        end
      end
    end
    

    This will create the table with the single column "foobar" and the values.

提交回复
热议问题