I want to use migration to create table in yii2.0.6. But i’m facing a difficulty the tables are created in my database but the check constraint doesn’t work. That’s when i enter a value that should be.rejected, the DBMS accepts it without any error.
I read the comment of the check(string$check),method in yii/db/ColumnSchemaBuilder class. It is say that the $check attribute is the SQL of the check contraint but i don’t have example of using it. Could someone help me?regards!
This is what i write in my up() function:
$this->createTable('{{℅user}}'), [
'id'=>$this->primaryKey (),
....,
'role'=>$this->string(10)->check("role in ('admin', 'member'))"