Using this gem: https://github.com/vprokopchuk256/mv-core you can do it in 
this way:

def change
   create_table :foo do |t|
       t.text :name, presence: true, custom: { statement: 'TRIM({name}) = 
{name}', as: :check }
   end
end

Best regards, 
Valeriy Prokopchuk

пʼятниця, 25 квітня 2008 р. 05:36:29 UTC+3 користувач Sean Chittenden 
написав:
>
> Is there some magic that's required to have db/schema.rb contain 
> various execute() methods that exist in the migrations files? 
>
> For example, suppose in a migration I have the following: 
>
> ### BEGIN 
> create_table 'foo' do |t| 
>   t.text :name, :null => false 
> end 
>
> execute "ALTER TABLE public.foo ADD CHECK(trim(name) = name AND 
> length(name) > 2)" 
> ### END 
>
> Is there a way to preserve this extra DDL foo so that it's preserved 
> in db/schema.rb?  As is, the rake test framework is arguably broken 
> for PostgreSQL because the db/schema.rb is always recreated without 
> the other DDL required to make a functional schema for the 
> application. 
>
> Is that a fair assessment? 
>
> -sc 
>

-- 
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/54833560-0181-4fa6-9d7c-0f31c5a11d8d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to