Jason Cameron
2011-Mar-02 17:35 UTC
How to generate an sql comment using a migration file?
I''d like to use migrations to add/remove/modify columns from a database. Rails makes that relatively painless. One feature I don''t see is the ability to comment on columns in the schema. How can I add a column comment to a migration? We''re using Oracle/PosgreSQL (and we''re thinking of adding SQL Server in the future.) The SQL for adding a comment to a column is oddly enough the same for all three it seems but I''d rather not take a chance. COMMENT ON COLUMN table_name.column_name IS ''Random Comment''; Thanks in advance, M -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Robert Walker
2011-Mar-03 06:30 UTC
Re: How to generate an sql comment using a migration file?
Jason Cameron wrote in post #984994:> I''d like to use migrations to add/remove/modify columns from a database. > Rails makes that relatively painless. One feature I don''t see is the > ability to comment on columns in the schema. How can I add a column > comment to a migration? > > We''re using Oracle/PosgreSQL (and we''re thinking of adding SQL Server in > the future.) > > The SQL for adding a comment to a column is oddly enough the same for > all three it seems but I''d rather not take a chance. > > COMMENT ON COLUMN table_name.column_name IS ''Random Comment'';It''s possible run whatever SQL you like using "execute" in a migration. I don''t think this is a common enough problem to add to the DSL of migrations. So for the above add this to your migration: execute "COMMENT ON COLUMN table_name.column_name IS ''Random Comment''" -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.