小编Hiy*_*uri的帖子

laravel 错误 1071 密钥太长 php artisan migrate

我正在使用 Laravel 并且我有功能迁移:

public function up()
    {
        Schema::create('products', function (Blueprint $table) {
            $table->increments('id');
            $table->string('title')->unique();
            $table->string('slug')->unique();
            $table->string('subtitle');
            $table->integer('price');
            $table->text('description');
            $table->boolean('featured')->default(false);
            $table->timestamps();
 
        });
    }            
Run Code Online (Sandbox Code Playgroud)

当我在我的 cmd 上执行“php artisan migrate”时出现错误

Migration table created successfully.
Migrating: 2014_10_12_000000_create_users_table

   Illuminate\Database\QueryException

  SQLSTATE[42000]: Syntax error or access violation: 1071 La clé est trop longue. Longueur maximale: 1000 (SQL: alter table `users` add unique `users_username_unique`(`username`))

  at C:\Users\linda\lynda-master\vendor\laravel\framework\src\Illuminate\Database\Connection.php:671
    667|         // If an exception occurs when attempting to run a query, we'll format the error
    668|         // message to include the …
Run Code Online (Sandbox Code Playgroud)

mysql wampserver php-7 laravel-7

-1
推荐指数
1
解决办法
3535
查看次数

标签 统计

laravel-7 ×1

mysql ×1

php-7 ×1

wampserver ×1