Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It is impossible to create a comment to a field. MSSQL #15880

Closed
t3mnikov opened this issue Mar 12, 2018 · 5 comments
Closed

It is impossible to create a comment to a field. MSSQL #15880

t3mnikov opened this issue Mar 12, 2018 · 5 comments
Milestone

Comments

@t3mnikov
Copy link

What steps will reproduce the problem?

$ yii migrate

What is the expected result?

$ yii migrate
Yii Migration Tool (based on Yii v2.0.14.1)

Total 1 new migration to be applied:
m180312_073238_review_table.php

Apply the above migration? (yes|no) [no]:y
*** applying m180312_073238_review_table
> create table foo ... done (time: 0.054s)
*** applied m180312_073238_review_table (time: 0.073s)

1 migration was applied.

Migrated up successfully.

What do you get instead?

Apply the above migration? (yes|no) [no]:y
*** applying m180312_073238_review_table
> create table review ...Exception: SQLSTATE[42000]: [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]В процедуре "sp_updateextendedproperty" указан неправильный параметр или значение.
The SQL being executed was: sp_updateextendedproperty @name = N'MS_Description', @value = 'id пользователя', @level1type = N'Table', @level1name = [review], @level2type = N'Column', @level2name = [user_id] (/home/xandr/Projects/vipishinew/vendor/yiisoft/yii2/db/Schema.php:664)
#0 /home/xandr/Projects/vipishinew/vendor/yiisoft/yii2/db/Command.php(1260): yii\db\Schema->convertException(Object(PDOException), 'sp_updateextend...')
#1 /home/xandr/Projects/vipishinew/vendor/yiisoft/yii2/db/Command.php(1072): yii\db\Command->internalExecute('sp_updateextend...')
#2 /home/xandr/Projects/vipishinew/vendor/yiisoft/yii2/db/Migration.php(326): yii\db\Command->execute()
#3 /home/xandr/Projects/vipishinew/console/migrations/m180312_073238_review_table.php(18): yii\db\Migration->createTable('review', Array)
#4 /home/xandr/Projects/vipishinew/vendor/yiisoft/yii2/db/Migration.php(114): m180312_073238_review_table->safeUp()
#5 /home/xandr/Projects/vipishinew/vendor/yiisoft/yii2/console/controllers/BaseMigrateController.php(725): yii\db\Migration->up()
#6 /home/xandr/Projects/vipishinew/vendor/yiisoft/yii2/console/controllers/BaseMigrateController.php(199): yii\console\controllers\BaseMigrateController->migrateUp('m180312_073238_...')
#7 [internal function]: yii\console\controllers\BaseMigrateController->actionUp(0)
#8 /home/xandr/Projects/vipishinew/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#9 /home/xandr/Projects/vipishinew/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#10 /home/xandr/Projects/vipishinew/vendor/yiisoft/yii2/console/Controller.php(148): yii\base\Controller->runAction('', Array)
#11 /home/xandr/Projects/vipishinew/vendor/yiisoft/yii2/base/Module.php(528): yii\console\Controller->runAction('', Array)
#12 /home/xandr/Projects/vipishinew/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('migrate', Array)
#13 /home/xandr/Projects/vipishinew/vendor/yiisoft/yii2/console/Application.php(147): yii\console\Application->runAction('migrate', Array)
#14 /home/xandr/Projects/vipishinew/vendor/yiisoft/yii2/base/Application.php(386): yii\console\Application->handleRequest(Object(yii\console\Request))
#15 /home/xandr/Projects/vipishinew/yii(31): yii\base\Application->run()
#16 {main}
*** failed to apply m180312_073238_review_table (time: 0.029s)

0 from 1 migrations were applied.

Migration failed. The rest of the migrations are canceled.

Additional info

createTable('review', [ 'id' => $this->primaryKey(), 'user_id' => $this->integer()->comment('id пользователя'), 'content' => $this->text()->comment('содержимое') ]); } /** * {@inheritdoc} */ public function safeDown() { $this->dropTable('review'); } } | Q | A | ---------------- | --- | Yii version | 2.0.14.1 | PHP version | 7.0.25 | Operating system | Ubuntu 16.04
@samdark samdark added MSSQL type:bug Bug status:to be verified Needs to be reproduced and validated. labels Mar 12, 2018
@samdark samdark added this to the 2.0.15 milestone Mar 12, 2018
@SilverFire
Copy link
Member

@t3mnikov спасибо за сообщение об ошибке. Хотели бы попробовать исправить проблему и прислать Pull Request?

@t3mnikov
Copy link
Author

Дмитрий, спасибо за оперативность и спасибо за предложение. На данный момент у меня нет решения. Я сообщу Вам дополнительно, если кто-то раньше меня не сделает этот фикс.

@sergeymakinen
Copy link
Member

А какая версия MSSQL?

@t3mnikov
Copy link
Author

t3mnikov commented Mar 12, 2018

@sergeymakinen, привет!
У меня:
Microsoft SQL Server 2017 (RTM-CU4) (KB4056498) - 14.0.3022.28 (X64) Feb 9 2018 19:39:09 Copyright (C) 2017 Microsoft Corporation Developer Edition (64-bit) on Linux (Ubuntu 16.04.4 LTS)

Я начал разбирать метод добавления комментария при MSSQL, в строке 259 указан вызов процедуры sp_updateextendedproperty.

  1. "sp_updateextendedproperty" нужно заменить на "sp_addextendedproperty", так как еще не создано property, которое мы хотим создать.
  2. Нужно добавить два входных параметра для процедуры "sp_addextendedproperty", такие как @level0type = N'Schema', @level0name = N'dbo',
    Описание тут
  3. Нужно пересмотреть метод "addCommentOnTable", скорее всего он тоже не рабочий.
  4. Еще нужно подумать на тем, что если я в следующей миграции захочу переименовать заданный комментарий у объекта (например, у той же колонки)

К таким выводам я пришел. Возможно я где-то ошибся.

@sergeymakinen
Copy link
Member

@t3mnikov, привет! Спасибо за подробный ответ.
Посмотрел, почитал https://stackoverflow.com/questions/9018518/how-to-add-a-comment-to-an-existing-table-column-in-sql-server (особенно комментарии к ответам): похоже, что всё именно так.

@samdark samdark removed this from the 2.0.16 milestone Oct 26, 2018
@samdark samdark added status:ready for adoption Feel free to implement this issue. and removed status:to be verified Needs to be reproduced and validated. labels Oct 26, 2018
alexkart added a commit to alexkart/yii2 that referenced this issue Jul 5, 2019
@samdark samdark added this to the 2.0.23 milestone Jul 5, 2019
@samdark samdark added status:under development Someone is working on a pull request. and removed status:ready for adoption Feel free to implement this issue. labels Jul 5, 2019
@samdark samdark removed the status:under development Someone is working on a pull request. label Jul 9, 2019
@samdark samdark closed this as completed Jul 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants