How can I add a CHECK .. IN constraint, like in the code below, in Doctrine 2?
CREATE TABLE table_name (
colum_name VARCHAR(1)
CHECK (column_name IN ('A','B','C'))
);
— edit: I use annotations to define my entities
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This is not supported by the ORM itself. You can define custom DDL to be used for those columns through your metadata driver. For instance, in the
AnnotationDriveryou can use/** @Column(type="string", columnDefinition="VARCHAR(1) CHECK (column_name IN ('A','B','C'))") */as defined in the Annotations Reference.I would avoid it anyway and keep those checks on application level.