4
votes

I am deploying a SF2.1 project into production.
I have customized the user model so that certain fields are required.
So when I try to create my super admin

$ php app/console fos:user:create admin [email protected] my_pass --super-admin

I'm getting

[PDOException]
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'my_required_field' cannot be null

What is the clean way to manage that ?
I Imagine not manually inserting the user into the table...

2

2 Answers

6
votes

You should override FOSUserBundle execute() method in /Command/CreateUserCommand.php and create() method in /Util/UserManipulator.php files. By doing that you should be able to add any additional fields to your User entity from the command line.

3
votes

You can either override the CLI command in order to provide the required field, or just provide a default value in class constructor in case it is a scalar.