Can't use fos:user:create
Guilllaum opened this issue · comments
When we want to create user or super-admin in command line, there is a bug:
`$ php app/console fos:user:create guillaum --super-admin
[Doctrine\DBAL\Driver\PDOException]
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'terms_accepted' cannot be null`
Hello @Guillawme,
Please use the UserBundle DataFixtures to create your users, as per the existing example ones, since the user entity has be enhanced with extra fields that are set as required and not null.
$admin = new User();
$admin->setCreatedAt(new \DateTime());
$admin->setUpdatedAt(new \DateTime());
$admin->setUsername('administrator');
$admin->setUsernameCanonical('administrator');
$admin->setEmail('admin@domain.com');
$admin->setEmailCanonical('admin@domain.com');
$admin->setEnabled(1);
$admin->setIsSystemUser(1);
$admin->setPlainPassword('Admin1234');
$admin->setConfirmed(true);
$admin->setTermsAccepted(true);
$admin->setSuperAdmin(true);
$manager->persist($admin);
You can then load the new user with php app/console doctrine:fixtures:load command.
Let me know if you still have an issue with this (for v2.8.11).
Hello @Guillawme,
Regardless, I have lifted the not null constraint from the fields that where causing the issue so you can now create your user as expected with
php app/console fos:user:create guillaum --super-admin