Forum: Ruby on Rails MYSQL COLUMN TYPE SET

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Dave (Guest)
on 2009-01-18 14:55
(Received via mailing list)
Is it possible to use Mysql column type SET within RoR migration files?
Teedub (Guest)
on 2009-01-18 17:08
(Received via mailing list)
I am not familiar with "SET" but you can pass any sql in a migration
with the "Execute" command
Like so: (this is adding a foreign key and a GUID id rather than an
auto-increment integer, but you get the point.)

class CreateSeats < ActiveRecord::Migration
  def self.up

    create_table(:seats,  :id => false) do |t|
      t.string :id, :limit => 32, :null => false
      t.string :venue_id, :limit => 32, :null => false
      t.string :name
      t.string :section
      t.string :seat_row
      t.string :seat_number
      t.string :seat_type

    execute "ALTER TABLE `seats` ADD PRIMARY KEY (`id`)"

    #add a foreign key
    execute "ALTER TABLE seats ADD CONSTRAINT fk_seats_venues FOREIGN
KEY (venue_id) REFERENCES venues(id)"


  def self.down
    #Drop foreign key
    execute "ALTER TABLE seats DROP FOREIGN KEY fk_seats_venues"
    drop_table :seats
Nectom (Guest)
on 2009-01-18 17:16
(Received via mailing list)
Thank you Teedub Ill pass it as an sql statement guess that's the
way :)
This topic is locked and can not be replied to.