Define default value in Doctrine annotation
Setting defaults on the database level makes a lot of sense to prevent the chance of issues arising in the application. Having the configuration for it in the Doctrine annotations makes things easier because you can also automatically generate migrations for it.
In MySQL the keyword to use is DEFAULT
. Doctrine doesn't have a special attribute in the column definition, but you can set it in the options
like the following:
/**
* @var string
*
* @ORM\Column(type="string", options={"default": "CREATED"})
*/
private $status = self::STATUS_CREATED;