Hello i have 1 table parent and have 3 child table from table parent .
and i create migration like this
A.Parent
public function up()
{
Schema::create('kegiatan', function (Blueprint $table) {
$table->id();
$table->string('kode_rekening');
$table->string('uraian');
$table->string('anggaran');
$table->string('anggaran_perubahan')->nullable();
$table->timestamps();
$table->softDeletes();
});
}
B. Child no 1
public function up()
{
Schema::create('uraian', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('kegiatan_id');
$table->string('kode_rekening');
$table->string('uraian');
$table->string('anggaran');
$table->string('anggaran_perubahan')->nullable();
$table->timestamps();
$table->softDeletes();
$table->foreign('kegiatan_id')->references('id')->on('kegiatan')->onDelete('cascade');
});
}
C. Child no 3
public function up()
{
Schema::create('uraian_kegiatan', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('uraian_id');
$table->string('kode_rekening');
$table->string('uraian');
$table->string('anggaran');
$table->string('anggaran_perubahan')->nullable();
$table->timestamps();
$table->softDeletes();
$table->foreign('uraian_id')->references('id')->on('uraian')->onDelete('cascade');
});
}
all is relate by foreign_key . i try to delete data on parent table like id 1 . but on my child , this data not deleted too . i think this is wrong because i set on delete casscade . i use Mysql and try to add 'InooDB' on my "config/Database" like this :
'mysql' => [
'driver' => 'mysql',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'prefix_indexes' => true,
'strict' => true,
'engine' => 'InnoDB',
'options' => extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
]) : [],
],
but its still didnt work , on first i see on this config/database ,this engine is set by 'null' ,
someone can help about this ? or give solution ? thanks you