yiisoft / yii2

Yii 2: The Fast, Secure and Professional PHP Framework
http://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
14.24k stars 6.91k forks source link

Wrong DROP TRIGGER implementation for SQLSERVER #11896

Closed bquartz closed 8 years ago

bquartz commented 8 years ago

What steps will reproduce the problem?

Using a SqlServer DB, run the migrations for RBAC Yii module. Then run the migrate/down command.

What is the expected result?

Migrations are reverted.

What do you get instead?

*** reverting m140506_102106_rbac_init
    > execute SQL: DROP dbo.trigger_auth_item_child; ...Exception: SQLSTATE[42000]: [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Unknown object type 'dbo' used in a CREATE, DROP, or ALTER statement.
The SQL being executed was: DROP dbo.trigger_auth_item_child; (D:\oms\vendor\yiisoft\yii2\db\Schema.php:633)
#0 D:\oms\vendor\yiisoft\yii2\db\Command.php(854): yii\db\Schema->convertException(Object(PDOException), 'DROP dbo.trigge...')
#1 D:\oms\vendor\yiisoft\yii2\db\Migration.php(175): yii\db\Command->execute()
#2 D:\oms\vendor\yiisoft\yii2\rbac\migrations\m140506_102106_rbac_init.php(141): yii\db\Migration->execute('DROP dbo.trigge...')
#3 D:\oms\vendor\yiisoft\yii2\console\controllers\BaseMigrateController.php(537): m140506_102106_rbac_init->down()
#4 D:\oms\vendor\yiisoft\yii2\console\controllers\BaseMigrateController.php(191): yii\console\controllers\BaseMigrateController->migrateDown('m140506_102106_...')
#5 [internal function]: yii\console\controllers\BaseMigrateController->actionDown('all')
#6 D:\oms\vendor\yiisoft\yii2\base\InlineAction.php(55): call_user_func_array(Array, Array)
#7 D:\oms\vendor\yiisoft\yii2\base\Controller.php(154): yii\base\InlineAction->runWithParams(Array)
#8 D:\oms\vendor\yiisoft\yii2\console\Controller.php(119): yii\base\Controller->runAction('down', Array)
#9 D:\oms\console\migrations\m160704_220329_init.php(33): yii\console\Controller->runAction('down', Array)
#10 D:\oms\vendor\yiisoft\yii2\db\Migration.php(121): m160704_220329_init->safeDown()
#11 D:\oms\vendor\yiisoft\yii2\console\controllers\BaseMigrateController.php(537): yii\db\Migration->down()
#12 D:\oms\vendor\yiisoft\yii2\console\controllers\BaseMigrateController.php(191): yii\console\controllers\BaseMigrateController->migrateDown('m160704_220329_...')
#13 [internal function]: yii\console\controllers\BaseMigrateController->actionDown(1)
#14 D:\oms\vendor\yiisoft\yii2\base\InlineAction.php(55): call_user_func_array(Array, Array)
#15 D:\oms\vendor\yiisoft\yii2\base\Controller.php(154): yii\base\InlineAction->runWithParams(Array)
#16 D:\oms\vendor\yiisoft\yii2\console\Controller.php(119): yii\base\Controller->runAction('down', Array)
#17 D:\oms\vendor\yiisoft\yii2\base\Module.php(454): yii\console\Controller->runAction('down', Array)
#18 D:\oms\vendor\yiisoft\yii2\console\Application.php(176): yii\base\Module->runAction('migrate/down', Array)
#19 D:\oms\vendor\yiisoft\yii2\console\Application.php(143): yii\console\Application->runAction('migrate/down', Array)
#20 D:\oms\vendor\yiisoft\yii2\base\Application.php(375): yii\console\Application->handleRequest(Object(yii\console\Request))
#21 D:\oms\yii(27): yii\base\Application->run()
#22 {main}
*** failed to revert m160704_220329_init (time: 3.416s)

Additional info

It must use DROP TRIGGER dbo.trigger_auth_item_child to drop a trigger.

Q A
Yii version 2.0.8
PHP version 5.6.12
Operating system Windows 10
SQL Server 2012 R2
samdark commented 8 years ago

Would you like to send a pull request fixing it?