Ruby on Rails
Friday, January 23, 2015
There is special gem that makes it possible. See https://github.com/vprokopchuk256/mv-core for details.
-- With that gem you can do it in this way:
def up
change_table :table_name do
t.change :check_constraint_name, :integer, inclusion: { in: [1, 2, 3], as: :check }
end
end
Best regards,
Valeriy Prokopchuk
понеділок, 25 лютого 2013 р. 12:17:28 UTC+2 користувач Sumit Srivastava написав:
понеділок, 25 лютого 2013 р. 12:17:28 UTC+2 користувач Sumit Srivastava написав:
Hi,
I have to add contraints (CHECK) on a sql table through rails migration. How should I? I googled and got to know about using something as follows,
def self.up
execute "ALTER TABLE table_name ADD CONSTRAINT check_constraint_name CHECK (check_column_name IN (1, 2, 3) )"
end
But am not sure if it appropriate to implement it this way or if there is any better method to get it done?
Regards,
Sumit
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/c0a6f4be-a073-45c4-b68a-8819c88b78ae%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment