Skip to content
This repository has been archived by the owner on Feb 17, 2023. It is now read-only.

Help in php yii migrate #86

Closed
FullHeleno opened this issue Mar 4, 2019 · 2 comments
Closed

Help in php yii migrate #86

FullHeleno opened this issue Mar 4, 2019 · 2 comments

Comments

@FullHeleno
Copy link

*** applying m180110_204953_create_account_table
> create table account ...Exception 'yii\db\Exception' with message 'SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes
The SQL being executed was: CREATE TABLE account (
id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
username varchar(255) NOT NULL UNIQUE,
profile_pic_url varchar(255),
full_name varchar(255),
biography varchar(255),
external_url varchar(255),
instagram_id varchar(255),
updated_at datetime,
created_at datetime,
monitoring tinyint(1) NOT NULL DEFAULT 0
)'

in /Applications/XAMPP/xamppfiles/htdocs/igmonitoring/vendor/yiisoft/yii2/db/Schema.php:664

Error Info:
Array
(
[0] => 42000
[1] => 1071
[2] => Specified key was too long; max key length is 767 bytes
)

Stack trace:
#0 /Applications/XAMPP/xamppfiles/htdocs/igmonitoring/vendor/yiisoft/yii2/db/Command.php(1295): yii\db\Schema->convertException(Object(PDOException), 'CREATE TABLE a...') #1 /Applications/XAMPP/xamppfiles/htdocs/igmonitoring/vendor/yiisoft/yii2/db/Command.php(1091): yii\db\Command->internalExecute('CREATE TABLE a...')
#2 /Applications/XAMPP/xamppfiles/htdocs/igmonitoring/vendor/yiisoft/yii2/db/Migration.php(323): yii\db\Command->execute()
#3 /Applications/XAMPP/xamppfiles/htdocs/igmonitoring/migrations/m180110_204953_create_account_table.php(25): yii\db\Migration->createTable('account', Array)
#4 /Applications/XAMPP/xamppfiles/htdocs/igmonitoring/vendor/yiisoft/yii2/console/controllers/BaseMigrateController.php(725): m180110_204953_create_account_table->up()
#5 /Applications/XAMPP/xamppfiles/htdocs/igmonitoring/vendor/yiisoft/yii2/console/controllers/BaseMigrateController.php(199): yii\console\controllers\BaseMigrateController->migrateUp('m180110_204953_...')
#6 [internal function]: yii\console\controllers\BaseMigrateController->actionUp(0)
#7 /Applications/XAMPP/xamppfiles/htdocs/igmonitoring/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#8 /Applications/XAMPP/xamppfiles/htdocs/igmonitoring/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#9 /Applications/XAMPP/xamppfiles/htdocs/igmonitoring/vendor/yiisoft/yii2/console/Controller.php(148): yii\base\Controller->runAction('', Array)
#10 /Applications/XAMPP/xamppfiles/htdocs/igmonitoring/vendor/yiisoft/yii2/base/Module.php(528): yii\console\Controller->runAction('', Array)
#11 /Applications/XAMPP/xamppfiles/htdocs/igmonitoring/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('migrate', Array)
#12 /Applications/XAMPP/xamppfiles/htdocs/igmonitoring/vendor/yiisoft/yii2/console/Application.php(147): yii\console\Application->runAction('migrate', Array)
#13 /Applications/XAMPP/xamppfiles/htdocs/igmonitoring/vendor/yiisoft/yii2/base/Application.php(386): yii\console\Application->handleRequest(Object(yii\console\Request))
#14 /Applications/XAMPP/xamppfiles/htdocs/igmonitoring/yii(20): yii\base\Application->run()
#15 {main}

@FullHeleno
Copy link
Author

Changing the bank collaction to utf8 I can migrate the bank to the step below, even after giving alter table to utf8mb4, of this error.

php yii migrate
Yii Migration Tool (based on Yii v2.0.16)

Total 8 new migrations to be applied:
m180628_113634_add_user_id_column_to_account_tag_table
m180820_114348_add_is_valid_column_to_account_table
m180820_114742_create_account_invalidation_type_table
m180820_175219_drop_is_private_column_from_account_table
m180823_132444_chg_account_disable_flag
m180830_063332_create_tag_invalidation_type_table
m181006_154743_chg_account_table
m181006_155930_chg_account_stats_table

Apply the above migrations? (yes|no) [no]:yes
*** applying m180628_113634_add_user_id_column_to_account_tag_table
> drop primary key PRIMARY ...Exception: SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP 'PRIMARY'; check that column/key exists
The SQL being executed was: ALTER TABLE account_tag DROP PRIMARY KEY (/Applications/XAMPP/xamppfiles/htdocs/igmonitoring/vendor/yiisoft/yii2/db/Schema.php:664)
#0 /Applications/XAMPP/xamppfiles/htdocs/igmonitoring/vendor/yiisoft/yii2/db/Command.php(1295): yii\db\Schema->convertException(Object(PDOException), 'ALTER TABLE ac...') #1 /Applications/XAMPP/xamppfiles/htdocs/igmonitoring/vendor/yiisoft/yii2/db/Command.php(1091): yii\db\Command->internalExecute('ALTER TABLE ac...')
#2 /Applications/XAMPP/xamppfiles/htdocs/igmonitoring/vendor/yiisoft/yii2/db/Migration.php(449): yii\db\Command->execute()
#3 /Applications/XAMPP/xamppfiles/htdocs/igmonitoring/migrations/m180628_113634_add_user_id_column_to_account_tag_table.php(15): yii\db\Migration->dropPrimaryKey('PRIMARY', 'account_tag')
#4 /Applications/XAMPP/xamppfiles/htdocs/igmonitoring/vendor/yiisoft/yii2/db/Migration.php(114): m180628_113634_add_user_id_column_to_account_tag_table->safeUp()
#5 /Applications/XAMPP/xamppfiles/htdocs/igmonitoring/vendor/yiisoft/yii2/console/controllers/BaseMigrateController.php(725): yii\db\Migration->up()
#6 /Applications/XAMPP/xamppfiles/htdocs/igmonitoring/vendor/yiisoft/yii2/console/controllers/BaseMigrateController.php(199): yii\console\controllers\BaseMigrateController->migrateUp('m180628_113634_...')
#7 [internal function]: yii\console\controllers\BaseMigrateController->actionUp(0)
#8 /Applications/XAMPP/xamppfiles/htdocs/igmonitoring/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#9 /Applications/XAMPP/xamppfiles/htdocs/igmonitoring/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#10 /Applications/XAMPP/xamppfiles/htdocs/igmonitoring/vendor/yiisoft/yii2/console/Controller.php(148): yii\base\Controller->runAction('', Array)
#11 /Applications/XAMPP/xamppfiles/htdocs/igmonitoring/vendor/yiisoft/yii2/base/Module.php(528): yii\console\Controller->runAction('', Array)
#12 /Applications/XAMPP/xamppfiles/htdocs/igmonitoring/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('migrate', Array)
#13 /Applications/XAMPP/xamppfiles/htdocs/igmonitoring/vendor/yiisoft/yii2/console/Application.php(147): yii\console\Application->runAction('migrate', Array)
#14 /Applications/XAMPP/xamppfiles/htdocs/igmonitoring/vendor/yiisoft/yii2/base/Application.php(386): yii\console\Application->handleRequest(Object(yii\console\Request))
#15 /Applications/XAMPP/xamppfiles/htdocs/igmonitoring/yii(20): yii\base\Application->run()
#16 {main}
*** failed to apply m180628_113634_add_user_id_column_to_account_tag_table (time: 0.098s)

0 from 8 migrations were applied.

Migration failed. The rest of the migrations are canceled.

@jakim
Copy link
Owner

jakim commented Mar 6, 2019

@jakim jakim closed this as completed May 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants