Anons79 Mini Shell

Directory : /home/aplikasiposinfo/.trash/database/migrations/
Upload File :
Current File : /home/aplikasiposinfo/.trash/database/migrations/2022_10_10_150643_make_relation_all_tables.php

<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;

class MakeRelationAllTables extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        DB::beginTransaction();
        try {
            Schema::table('jadwal_kerja_details', function (Blueprint $table) {
                $table->foreign('jadwal_kerja_id')->references('id')->on('jadwal_kerjas')->onDelete('cascade');
            });
            
            Schema::table('karyawans', function (Blueprint $table) {
                $table->foreign('user_id')->references('id')->on('users')->onDelete('no action');
                $table->foreign('perusahaan_id')->references('id')->on('perusahaans')->onDelete('no action');
                $table->foreign('departemen_id')->references('id')->on('departemens')->onDelete('cascade');
                $table->foreign('jabatan_id')->references('id')->on('jadwal_kerjas')->onDelete('no action');
            });
    
            Schema::table('lokasi_absen_karyawans', function (Blueprint $table) {
                $table->foreign('lokasi_absen_id')->references('id')->on('lokasi_absens')->onDelete('no action');
                $table->foreign('karyawan_id')->references('id')->on('karyawans')->onDelete('no action');
            });
    
            Schema::table('perusahaanables', function (Blueprint $table) {
                $table->foreign('perusahaan_id')->references('id')->on('perusahaans')->onDelete('no action');
            });
    
            Schema::table('kunjungans', function (Blueprint $table) {
                $table->foreign('karyawan_id')->references('id')->on('karyawans')->onDelete('no action');
            });
    
            Schema::table('timesheets', function (Blueprint $table) {
                $table->foreign('karyawan_id')->references('id')->on('karyawans')->onDelete('no action');
                $table->foreign('user_id')->references('id')->on('users')->onDelete('no action');
            });
    
            Schema::table('timesheet_details', function (Blueprint $table) {
                $table->foreign('timesheet_id')->references('id')->on('timesheets')->onDelete('no action');
            });
    
            Schema::table('reimbursements', function (Blueprint $table) {
                $table->foreign('karyawan_id')->references('id')->on('karyawans')->onDelete('no action');
                $table->foreign('reimbursement_category_id')->references('id')->on('reimbursement_categories')->onDelete('no action');
            });
    
            Schema::table('riwayat_absensis', function (Blueprint $table) {
                $table->foreign('absensi_id')->references('id')->on('absensis')->onDelete('cascade');
                $table->foreign('jadwal_kerja_id')->references('id')->on('jadwal_kerjas')->onDelete('cascade');
                $table->foreign('lokasi_absen_id')->references('id')->on('lokasi_absens')->onDelete('no action');
                $table->foreign('unit_id')->references('id')->on('units')->onDelete('no action');
            });
    
            Schema::table('izins', function (Blueprint $table) {
                $table->foreign('karyawan_id')->references('id')->on('karyawans')->onDelete('no action');
                $table->foreign('abensi_id')->references('id')->on('absensis')->onDelete('no action');
            });
    
            Schema::table('jadwal_kerja_karyawans', function (Blueprint $table) {
                $table->foreign('karyawan_id')->references('id')->on('karyawans')->onDelete('no action');
                $table->foreign('jadwal_kerja_id')->references('id')->on('jadwal_kerjas')->onDelete('no action');
            });
    
            Schema::table('kalender_jadwals', function (Blueprint $table) {
                $table->foreign('karyawan_id')->references('id')->on('karyawans')->onDelete('no action');
            });
    
            Schema::table('lokasi_kerja_karyawans', function (Blueprint $table) {
                $table->foreign('karyawan_id')->references('id')->on('karyawans')->onDelete('no action');
                $table->foreign('lokasi_kerja_id')->references('id')->on('lokasi_kerjas')->onDelete('no action');
            });
    
    
            
           
            
            Schema::table('user_departemens', function (Blueprint $table) {
                $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
                $table->foreign('departemen_id')->references('id')->on('departemens')->onDelete('cascade');
            });
            DB::commit();
        } catch (\Throwable $th) {
            DB::rollBack();
            throw $th;
        }
        

    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('jadwal_kerja_details', function (Blueprint $table) {
            $table->dropForeign(['jadwal_kerja_id']);
        });
        
        Schema::table('karyawans', function (Blueprint $table) {
            $table->dropForeign(['user_id','perusahaan_id','departemen_id','jabatan_id']);
        });

        Schema::table('lokasi_absen_karyawans', function (Blueprint $table) {
            $table->dropForeign(['lokasi_absen_id','karyawan_id']);
        });

        Schema::table('perusahaanables', function (Blueprint $table) {
            $table->dropForeign(['perusahaan_id']);
        });

        Schema::table('kunjungans', function (Blueprint $table) {
            $table->dropForeign(['karyawan_id']);
        });

        Schema::table('timesheets', function (Blueprint $table) {
            $table->dropForeign(['karyawan_id','user_id']);
        });

        Schema::table('timesheet_details', function (Blueprint $table) {
            $table->dropForeign(['timesheet_id']);
        });

        Schema::table('reimbursements', function (Blueprint $table) {
            $table->dropForeign(['karyawan_id','reimbursement_category_id']);
        });

        Schema::table('riwayat_absensis', function (Blueprint $table) {
            $table->dropForeign(['absensi_id','jadwal_kerja_id','lokasi_absen_id','unit_id']);
        });

        Schema::table('izins', function (Blueprint $table) {
            $table->dropForeign(['karyawan_id','abensi_id']);
        });

        Schema::table('jadwal_kerja_karyawans', function (Blueprint $table) {
            $table->dropForeign(['karyawan_id','jadwal_kerja_id']);
        });

        Schema::table('kalender_jadwals', function (Blueprint $table) {
            $table->dropForeign(['karyawan_id']);
        });

        Schema::table('lokasi_kerja_karyawans', function (Blueprint $table) {
            $table->dropForeign(['karyawan_id','lokasi_kerja_id']);
        });


        
       
        
        Schema::table('user_departemens', function (Blueprint $table) {
            $table->dropForeign(['user_id','departemen_id']);
        });
    }
}

Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]