AddForeignkeysToUsersTable
public function up()
{
Schema::table('users', function($table) {
$table->foreign('department_id')->references('id')->on('departments');
$table->foreign('role_id')->references('id')->on('roles');
});
}
public function down()
{
Schema::table('users', function($table){
$table->dropForeign('users_department_id_foreign');
$table->dropForeign('users_role_id_foreign');
$table->dropIndex('users_department_id_foreign');
$table->dropIndex('users_role_id_foreign');
});
}
AddForeignkeysToRolesTable
public function up()
{
Schema::table('roles', function($table) {
$table->foreign('department_id')->references('id')->on('departments');
});
}
public function down()
{
Schema::table('roles', function($table){
$table->dropForeign('roles_department_id_foreign');
$table->dropIndex('roles_department_id_foreign');
});
}
AddForeignkeysToTransactionsTable
public function up()
{
Schema::table('transactions', function($table) {
$table->foreign('department_id')->references('id')->on('departments');
});
}
public function down()
{
Schema::table('transactions', function($table){
$table->dropForeign('transactions_department_id_foreign');
$table->dropIndex('transactions_department_id_foreign');
});
}
AddForeignkeysToRolestransactionsTable
public function up()
{
Schema::table('rolestransactions', function($table) {
$table->foreign('transaction_id')->references('id')->on('transactions');
$table->foreign('role_id')->references('id')->on('roles');
});
}
public function down()
{
Schema::table('rolestransactions', function($table){
$table->dropForeign('rolestransactions_transaction_id_foreign');
$table->dropForeign('rolestransactions_role_id_foreign');
$table->dropIndex('rolestransactions_transaction_id_foreign');
$table->dropIndex('rolestransactions_role_id_foreign');
});
}