Is it possible to use Mysql column type SET within RoR migration files? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 t.timestamps end 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)" end def self.down #Drop foreign key execute "ALTER TABLE seats DROP FOREIGN KEY fk_seats_venues" drop_table :seats end end On Jan 18, 12:35 am, Dave <nec...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Is it possible to use Mysql column type SET within RoR migration files?--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thank you Teedub Ill pass it as an sql statement guess that''s the easiest way :) On Sun, Jan 18, 2009 at 3:06 PM, Teedub <twscannell-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > 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 > > t.timestamps > end > 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)" > > end > > def self.down > #Drop foreign key > execute "ALTER TABLE seats DROP FOREIGN KEY fk_seats_venues" > drop_table :seats > end > end > > > > > On Jan 18, 12:35 am, Dave <nec...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Is it possible to use Mysql column type SET within RoR migration files? > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---