2016-05-14 85 views
-1

導軌分貝:遷移 給出錯誤:= 類型 「email_must_be_company_email」 不存在..PostgreSQL中,添加約束誤差

遷移文件是............

class AddEmailConstraintToUsers < ActiveRecord::Migration 
    def up 
    execute %{ 
     ALTER TABLE users 
     ADD CONTRAINT ***email_must_be_company_email*** 
     CHECK (email ~* '^[^@][email protected]\\.com' ) 
     } 
    end 

    def down 
    execute %{ 
     ALTER TABLE users 
     DROP CONTRAINT ***email_must_be_company_email*** 
    } 
end 
end 

回答

0

你拼錯了單詞,作爲約束這樣CONTRAINT Postgres的是將其解釋爲列名和email_must_be_company_email作爲列類型。