علیرضا مه آبادی
1 سال پیش توسط علیرضا مه آبادی مطرح شد
1 پاسخ

ارور مایگریشن

درود بنده چندین جدول دارم و اولین جدولم user هست و هر وقت php artisan migrate:rollback میزنم این ارور برای جدول users میده مشکل نمیدونم از چی هست.

  INFO  Rolling back migrations.

  2014_10_12_000000_create_users_table ................................................................................................... 45ms FAIL 

   Illuminate\Database\QueryException  

  SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (SQL: drop table if exists `users`)   

  at C:\Users\aseman\CoffeeShop\vendor\laravel\framework\src\Illuminate\Database\Connection.php:760
    756▕         // If an exception occurs when attempting to run a query, we'll format the error 
    757▕         // message to include the bindings with SQL, which will make this exception a
    758▕         // lot more helpful to the developer instead of just the database's errors.
    759▕         catch (Exception $e) {
  ➜ 760▕             throw new QueryException(
    761▕                 $query, $this->prepareBindings($bindings), $e
    762▕             );
    763▕         }
    764▕     }

  1   C:\Users\aseman\CoffeeShop\vendor\laravel\framework\src\Illuminate\Database\Connection.php:545 
      PDOException::("SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails")

  2   C:\Users\aseman\CoffeeShop\vendor\laravel\framework\src\Illuminate\Database\Connection.php:545
      PDOStatement::execute()

اینم جدول users

  Schema::create('users', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->string('email')->unique();
            $table->timestamp('email_verified_at')->nullable();
            $table->string('password');
            $table->rememberToken();
            $table->timestamps();
        });

ثبت پرسش جدید
lara
تخصص : طراح
@mehditaheri204 1 سال پیش آپدیت شد
0

بنظرم کاربر در یک جدول دیگر هست که پاک نمیشه که جدول رفرش بشه . یک همچین حالتی هست

 onDelete('cascade')

برای ارسال پاسخ لازم است وارد شده یا ثبت‌نام کنید

ورود یا ثبت‌نام