Tuesday, April 11, 2017

Laravel Database - PDOException Integrity constraint violation Cannot delete or update

use laravel 5.2.* i have a problem error with database, currently database table :

  Schema::create('telepon', function (Blueprint $table) {
        $table->timestamps();
        $table->integer('id_siswa')->unsigned()->primary('id_siswa');
        $table->string('nomor_telepon')->unique();

        $table->foreign('id_siswa')
                ->references('id')->on('siswa')
                ->onDelete('cascade')
                ->onUpdate('cascade');
    });

and after migration i some problem the same with 'siswa' , in terminal :

  [Illuminate\Database\QueryException]                                         

SQLSTATE[23000]: Integrity constraint violation: 1217 Cannot delete or upda
te a parent row: a foreign key constraint fails (SQL: drop table siswa)

[PDOException]
SQLSTATE[23000]: Integrity constraint violation: 1217 Cannot delete or upda
te a parent row: a foreign key constraint fails

i have checked with migrate:reset migrate:refresh migrate:rollback with the same error

please help, thank you



via muhammad toha

Advertisement