Open juggernautt opened 6 years ago
Hi, I have the same problem:
*** applying m141207_001649_create_basic_user_permissions
Exception: SQLSTATE[25P02]: In failed sql transaction: 7 ERROR: current transaction is aborted, commands ignored until end of transaction block
The SQL being executed was: SELECT EXISTS(SELECT * FROM "auth_item" WHERE "name"='viewUserRoles') (/www/vendor/yiisoft/yii2/db/Schema.php:664)
#0 /www/vendor/yiisoft/yii2/db/Command.php(1263): yii\db\Schema->convertException(Object(PDOException), 'SELECT EXISTS(S...')
#1 /www/vendor/yiisoft/yii2/db/Command.php(1148): yii\db\Command->internalExecute('SELECT EXISTS(S...')
#2 /www/vendor/yiisoft/yii2/db/Command.php(425): yii\db\Command->queryInternal('fetchColumn', 0)
#3 /www/vendor/yiisoft/yii2/db/Query.php(425): yii\db\Command->queryScalar()
#4 /www/vendor/webvimark/module-user-management/models/rbacDB/AbstractItem.php(196): yii\db\Query->exists()
#5 [internal function]: webvimark\modules\UserManagement\models\rbacDB\AbstractItem->validateUniqueName('name', NULL, Object(yii\validators\InlineValidator))
#6 /www/vendor/yiisoft/yii2/validators/InlineValidator.php(72): call_user_func(Array, 'name', NULL, Object(yii\validators\InlineValidator))
#7 /www/vendor/yiisoft/yii2/validators/Validator.php(267): yii\validators\InlineValidator->validateAttribute(Object(webvimark\modules\UserManagement\models\rbacDB\Permission), 'name')
#8 /www/vendor/yiisoft/yii2/base/Model.php(367): yii\validators\Validator->validateAttributes(Object(webvimark\modules\UserManagement\models\rbacDB\Permission), Array)
#9 /www/vendor/yiisoft/yii2/db/ActiveRecord.php(509): yii\base\Model->validate(Array)
#10 /www/vendor/yiisoft/yii2/db/BaseActiveRecord.php(670): yii\db\ActiveRecord->insert(true, NULL)
#11 /www/vendor/webvimark/module-user-management/models/rbacDB/AbstractItem.php(67): yii\db\BaseActiveRecord->save()
#12 /www/console/migrations/m141207_001649_create_basic_user_permissions.php(58): webvimark\modules\UserManagement\models\rbacDB\AbstractItem::create('viewUserRoles', 'View user roles', 'userManagement')
Yii2 Framework v. 2.0.15
The problem is a FK error while inserting into auth_item_child table. After droping FK it's works.
I had the same issue.
Well, if I put a comment in m140611_133903_init_rbac.php to // 'FOREIGN KEY (child) REFERENCES ' . Yii::$app->getModule('user-management')->auth_item_table . ' (name) ON DELETE CASCADE ON UPDATE CASCADE' the migration really runs - seamlessly fine, but in fact: not fine.
When I compare the mysql dump, it seems that there are some rows that are missing from auth_item (name like '%/user-management/user-visit-log%').
And when I try to put back the deleted constraint: alter table auth_item_child add constraint "auth_item_child_child_fkey" FOREIGN KEY (child) REFERENCES auth_item(name) ON UPDATE CASCADE ON DELETE CASCADE; it warns: Key (child)=(/user-management/user-visit-log/index) is not present in table "auth_item".
(Otherwise I don't understand, why the error messages are so misleading, speaking about transactions. ?!???)
A workaround: I put back the missing rows, and after them the FK can be created.
insert into auth_item (name, type, created_at, updated_at, group_code) values
('/user-management/user-visit-log/*', 3, 1583316060, 1583316060, NULL),
('/user-management/user-visit-log/bulk-activate', 3, 1583316060, 1583316060, NULL),
('/user-management/user-visit-log/bulk-deactivate', 3, 1583316060, 1583316060, NULL),
('/user-management/user-visit-log/bulk-delete', 3, 1583316060, 1583316060, NULL),
('/user-management/user-visit-log/create', 3, 1583316060, 1583316060, NULL),
('/user-management/user-visit-log/delete', 3, 1583316060, 1583316060, NULL),
('/user-management/user-visit-log/grid-page-size', 3, 1583316060, 1583316060, NULL),
('/user-management/user-visit-log/grid-sort', 3, 1583316060, 1583316060, NULL),
('/user-management/user-visit-log/index', 3, 1583316060, 1583316060, NULL),
('/user-management/user-visit-log/toggle-attribute', 3, 1583316060, 1583316060, NULL),
('/user-management/user-visit-log/update', 3, 1583316060, 1583316060, NULL),
('/user-management/user-visit-log/view', 3, 1583316060, 1583316060, NULL);
alter table auth_item_child add constraint "auth_item_child_child_fkey" FOREIGN KEY (child) REFERENCES auth_item(name) ON UPDATE CASCADE ON DELETE CASCADE;
Hey guys, any solution for this bug? Greetings.
I think that for some reason the ORM is freezing the transaction with each entry of authitemgroup and its children.
I fix the error: 1.- customizing migrations, copying from the vendor, and placing them in a directory in my project.
Hello, I have fresh yii instalation and empty pg db. when I'm rinning migration command: ./yii migrate --migrationPath=vendor/webvimark/module-user-management/migrations/, i receive an error Exception: SQLSTATE[25P02]: In failed sql transaction: 7 ERROR: current transaction is aborted, commands ignored until end of transaction block The SQL being executed was: SELECT EXISTS(SELECT * FROM "auth_item" WHERE "name"='viewUserRoles') (/home/juggernautt/projects/yii-trial/vendor/yiisoft/yii2/db/Schema.php:663)
I've seen there were similar issues, but there was no coherent answer. Can you please advice what to do? Thanks