rails db:migrate 给出错误:= 类型" email_must_be_company_email"不存在..
迁移文件是............
class AddEmailConstraintToUsers < ActiveRecord::Migration
def up
execute %{
ALTER TABLE users
ADD CONTRAINT ***email_must_be_company_email***
CHECK ( email ~* '^[^@]+@example\\.com' )
}
end
def down
execute %{
ALTER TABLE users
DROP CONTRAINT ***email_must_be_company_email***
}
end
end
答案 0 :(得分:0)
您已将CONSTRAINT一词拼错为CONTRAINT,因此postgres将其解释为列名,并将email_must_be_company_email解释为列类型。