Форум Laravel - Болтовня - PullRequest
0 голосов
/ 04 июня 2019

Привет переполнение стека

Я пытаюсь установить thedevdojo / chatter для Laravel, но при запуске миграций происходит сбой, и я не могу понять, почему.

Здесь вы видите неудачные миграции.

public function up()
{
    Schema::table('chatter_discussion', function (Blueprint $table) {
        $table->foreign('chatter_category_id')->references('id')->on('chatter_categories')
                    ->onDelete('cascade')
                    ->onUpdate('cascade');
        $table->foreign('user_id')->references('id')->on('users')
                    ->onDelete('cascade')
                    ->onUpdate('cascade');
    });
    Schema::table('chatter_post', function (Blueprint $table) {
        $table->foreign('chatter_discussion_id')->references('id')->on('chatter_discussion')
                    ->onDelete('cascade')
                    ->onUpdate('cascade');
        $table->foreign('user_id')->references('id')->on('users')
                    ->onDelete('cascade')
                    ->onUpdate('cascade');
    });
}

public function down()
{
    Schema::table('chatter_discussion', function (Blueprint $table) {
        $table->dropForeign('chatter_discussion_chatter_category_id_foreign');
        $table->dropForeign('chatter_discussion_user_id_foreign');
    });
    Schema::table('chatter_post', function (Blueprint $table) {
        $table->dropForeign('chatter_post_chatter_discussion_id_foreign');
        $table->dropForeign('chatter_post_user_id_foreign');
    });
}

Здесь вы видите выброшенное исключение:

    Migrating: 2016_07_29_171128_create_foreign_keys

   Illuminate\Database\QueryException  : SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint (SQL: alter table `chatter_discussion` add constraint `chatter_discussion_user_id_foreign` foreign key (`user_id`) references `users` (`id`) on delete cascade on update cascade)

  at /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664
    660|         // If an exception occurs when attempting to run a query, we'll format the error
    661|         // message to include the bindings with SQL, which will make this exception a
    662|         // lot more helpful to the developer instead of just the database's errors.
    663|         catch (Exception $e) {
  > 664|             throw new QueryException(
    665|                 $query, $this->prepareBindings($bindings), $e
    666|             );
    667|         }
    668| 

  Exception trace:

  1   PDOException::("SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint")
      /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:458

  2   PDOStatement::execute()
      /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:458

  Please use the argument -v to see more details.

Я действительно надеюсь, что вы понимаете, что я делаю не так. Это, кстати, их стандартный файл оттуда github найден в Там Githib .

Спасибо за ваше время:)

1 Ответ

0 голосов
/ 04 июня 2019

Fixed.Отредактированы большие инкременты в пользовательской таблице с шагом

...