schmunk42/p3admin — Issue #1: add foreign key fk_authitem_parent CDbCommand failed to execute the SQL statement
Author: Marat
Created: 2011-10-15 21:02:18+00:00
State: open

> add foreign key fk_authitem_parent: AuthItemChild (parent) references authitem (name) ...exception 'CDbException' with message 'CDbCommand failed to execute the SQL statement: SQLSTATE[HY000]: General error: 1005 Can't create table 'p3_html_2011_10_16_02_51.#sql-41f_1e8' (errno: 150). The SQL statement executed was: ALTER TABLE `AuthItemChild` ADD CONSTRAINT `fk_authitem_parent` FOREIGN KEY (`parent`) REFERENCES `authitem` (`name`)' in /var/www/framework/framework/db/CDbCommand.php:336
Stack trace:
#0 /var/www/framework/framework/db/CDbCommand.php(1350): CDbCommand->execute()
#1 /var/www/framework/framework/db/CDbMigration.php(342): CDbCommand->addForeignKey('fk_authitem_par...', 'AuthItemChild', 'parent', 'authitem', 'name', NULL, NULL)
#2 /var/www/html_2011_10_16_02_51/protected/modules/p3admin/modules-install/rights/migrations/m110402_195159_init.php(61): CDbMigration->addForeignKey('fk_authitem_par...', 'AuthItemChild', 'parent', 'authitem', 'name', NULL, NULL)
#3 /var/www/framework/framework/cli/commands/MigrateCommand.php(363): m110402_195159_init->up()
#4 /var/www/framework/framework/cli/commands/MigrateCommand.php(100): MigrateCommand->migrateUp('m110402_195159_...')
#5 [internal function]: MigrateCommand->actionUp(Array)
#6 /var/www/framework/framework/console/CConsoleCommand.php(135): ReflectionMethod->invokeArgs(Object(MigrateCommand), Array)
#7 /var/www/framework/framework/console/CConsoleCommandRunner.php(63): CConsoleCommand->run(Array)
#8 /var/www/framework/framework/console/CConsoleApplication.php(88): CConsoleCommandRunner->run(Array)
#9 /var/www/framework/framework/base/CApplication.php(158): CConsoleApplication->processRequest()
#10 /var/www/framework/framework/yiic.php(33): CApplication->run()
#11 /var/www/html_2011_10_16_02_51/protected/yiic.php(7): require_once('/var/www/framew...')
#12 /var/www/html_2011_10_16_02_51/protected/yiic(4): require_once('/var/www/html_2...')
#13 {main}

file p3admin\modules-install\rights\migrations\m111013_235000_p3items.php

7 -	$this->insert("AuthItem", array(
8 -	"name" => "Editor",
9 -	"type" => "2",
10 -	"description" => "Content Editor (Widgets, Media Files)",
11 -	"bizrule" => null,
12 -	"data" => "N;",
13 -	));

23 +	$this->insert("AuthItem", array(
24 +	"name" => "Editor",
25 +	"type" => "2",
26 +	"description" => "Content Editor (Widgets, Media Files)",
27 +	"bizrule" => null,
28 +	"data" => "N;",
29 +	));