I didn't know that gem, I'll take a look on that.

With Postgres, you can use this one 
too: https://github.com/take-five/postgresql-check

Em sexta-feira, 23 de janeiro de 2015 18:33:37 UTC-2, Valera Prokopchuk 
escreveu:
>
> 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 
> написав:
>>
>> 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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/c71afd09-fdfb-400b-b290-48abe07ed423%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to