Yii2- Not able to insert/delete rows using console controller

I want to add a permission to user by using CreateCommand of yii2.
The entire code is executed and it does not display any error. But the row is not added to database.

Below is the code which I am using -
$mapSetting = Yii::$app->authManager->getPermission(‘mapSetting’);
if (!Yii::$app->authManager->checkAccess($userId, $mapSetting->name)) {
Yii::$app->authManager->assign($mapSetting, $userId);

There seems nothing wrong with the code itself. What kind of authManager are you using (PhpManager or DbManager)? Is the corrsponding file wirtable (or the corresponding database persistent and all pending transactions are commited)?

i am using DbManager and my code is running in webApplication
just in consoleApplication its not running

And both applications are running on the same system and are configured the same (at least the db and authManager component)?
Without the ability to look at more code I cannot think of the problem at hand. I would suggest to turn on debug mode (i.e. set YII_DEBUG constant to true in the yii entry script) and turn on logging (make sure to log levels trace and profile). Run the console command and check the logs. Verify that the database commands are executed properly and successfully.