asialong 2016-01-02 22:46:37 7605次浏览 2条回复 0 0 0

错误如下: 大神们,救命啊

e:\phpStudy\WWW\mywork>php yii migrate/up --migrationPath=@vendor/dektrium/yii2-
user/migrations
Yii Migration Tool (based on Yii v2.0.7-dev)

Creating migration history table "my_migration"...Done.
Total 10 new migrations to be applied:
        m140209_132017_init
        m140403_174025_create_account_table
        m140504_113157_update_tables
        m140504_130429_create_token_table
        m140830_171933_fix_ip_field
        m140830_172703_change_account_table_name
        m141222_110026_update_ip_field
        m141222_135246_alter_username_length
        m150614_103145_update_social_account_table
        m150623_212711_fix_username_notnull

Apply the above migrations? (yes|no) [no]:y
*** applying m140209_132017_init
    > create table {{%user}} ... done (time: 0.080s)
    > create unique index user_unique_username on {{%user}} (username) ... done
(time: 0.048s)
    > create unique index user_unique_email on {{%user}} (email) ... done (time:
 0.038s)
    > create unique index user_confirmation on {{%user}} (id, confirmation_token
) ... done (time: 0.036s)
    > create unique index user_recovery on {{%user}} (id, recovery_token) ... do
ne (time: 0.036s)
    > create table {{%profile}} ... done (time: 0.027s)
    > add foreign key fk_user_profile: {{%profile}} (user_id) references {{%user
}} (id) ... done (time: 0.038s)
*** applied m140209_132017_init (time: 0.326s)

*** applying m140403_174025_create_account_table
    > create table {{%account}} ... done (time: 0.026s)
    > create unique index account_unique on {{%account}} (provider,client_id) ..
.Exception 'yii\db\Exception' with message 'SQLSTATE[42000]: Syntax error or acc
ess violation: 1071 Specified key was too long; max key length is 1000 bytes
The SQL being executed was: ALTER TABLE `my_account` ADD UNIQUE INDEX `account_u
nique` (`provider`, `client_id`)'

in E:\phpStudy\WWW\mywork\vendor\yiisoft\yii2\db\Schema.php:628

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

Stack trace:
#0 E:\phpStudy\WWW\mywork\vendor\yiisoft\yii2\db\Command.php(793): yii\db\Schema
->convertException(Object(PDOException), 'ALTER TABLE `my...')
#1 E:\phpStudy\WWW\mywork\vendor\yiisoft\yii2\db\Migration.php(433): yii\db\Comm
and->execute()
#2 E:\phpStudy\WWW\mywork\vendor\dektrium\yii2-user\migrations\m140403_174025_cr
eate_account_table.php(30): yii\db\Migration->createIndex('account_unique', '{{%
account}}', Array, true)
#3 E:\phpStudy\WWW\mywork\vendor\yiisoft\yii2\console\controllers\BaseMigrateCon
troller.php(562): m140403_174025_create_account_table->up()
#4 E:\phpStudy\WWW\mywork\vendor\yiisoft\yii2\console\controllers\BaseMigrateCon
troller.php(151): yii\console\controllers\BaseMigrateController->migrateUp('m140
403_174025_...')
#5 [internal function]: yii\console\controllers\BaseMigrateController->actionUp(
0)
#6 E:\phpStudy\WWW\mywork\vendor\yiisoft\yii2\base\InlineAction.php(55): call_us
er_func_array(Array, Array)
#7 E:\phpStudy\WWW\mywork\vendor\yiisoft\yii2\base\Controller.php(154): yii\base
\InlineAction->runWithParams(Array)
#8 E:\phpStudy\WWW\mywork\vendor\yiisoft\yii2\console\Controller.php(104): yii\b
ase\Controller->runAction('up', Array)
#9 E:\phpStudy\WWW\mywork\vendor\yiisoft\yii2\base\Module.php(454): yii\console\
Controller->runAction('up', Array)
#10 E:\phpStudy\WWW\mywork\vendor\yiisoft\yii2\console\Application.php(167): yii
\base\Module->runAction('migrate/up', Array)
#11 E:\phpStudy\WWW\mywork\vendor\yiisoft\yii2\console\Application.php(143): yii
\console\Application->runAction('migrate/up', Array)
#12 E:\phpStudy\WWW\mywork\vendor\yiisoft\yii2\base\Application.php(375): yii\co
nsole\Application->handleRequest(Object(yii\console\Request))
#13 E:\phpStudy\WWW\mywork\yii(27): yii\base\Application->run()
#14 {main}
  • 回复于 2016-01-04 17:45 举报

    Specified key was too long; max key length is 1000 bytes

    1 条回复
    回复于 2016-01-07 09:16 回复

    是这个组件里的一个地方有错误,我改完后就可以了

  • 回复于 2016-04-30 10:50 举报

    楼主,您好,我现在也碰到跟您一样的问题,您最后是怎么解决的?求教一下

    1 条回复
    回复于 2016-04-30 18:53 回复

    m140403_174025_create_account_table
    这个文件里面的键关联要改一下就可以了

您需要登录后才可以回复。登录 | 立即注册