athenahr/database/migrations/2022_02_02_060702_create_absences_table.php
miguel456 a4f41b8f8d fix: add constraint actions to db structure
This commit adds several missing "cascade delete" actions to relationships on database tables. This effectively fixes errors while trying to delete user accounts because of pending child records.

Additionally, the observers for applications and vacancies were removed, since they are now obsolete.

The account deletion system was also refactored.
2022-03-07 18:14:42 +00:00

50 lines
1.3 KiB
PHP
Executable File

<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateAbsencesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('absences', function (Blueprint $table) {
$table->id();
$table->bigInteger('requesterID')->unsigned();
$table->date('start');
$table->date('predicted_end');
$table->boolean('available_assist');
$table->string('reason');
$table->enum('status', ['PENDING', 'APPROVED', 'DECLINED', 'CANCELLED', 'ENDED']);
$table->bigInteger('reviewer')->unsigned()->nullable();
$table->date('reviewed_date')->nullable();
$table->timestamps();
$table->foreign('requesterID')
->references('id')
->on('users')
->onDelete('cascade');
$table->foreign('reviewer')
->references('id')
->on('users')
->onDelete('set null');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('absences');
}
}