Added sub-bookings model and migration.

This commit is contained in:
Lukas Halbritter
2018-09-07 14:06:29 +02:00
parent 524378dcae
commit b01762fdfb
2 changed files with 71 additions and 0 deletions
@@ -0,0 +1,61 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateSubBookingsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('sub_bookings', function (Blueprint $table) {
$table->increments('id');
// The reference which describes the sub-booking
$table->string('reference');
// The amount of the subbooking
$table->float('amount', 8, 2);
// If the sub-booking belongs to the target of a person, this target
// is referenced here
$table->integer('person_target_id')->unsigned()->nullable();
$table->foreign('person_target_id')->references('id')->on('person_targets')
->onDelete('set null');
// Each sub-booking belongs to one (super-)booking. In the most
// simple case, a booking consists of exactly one sub-booking.
$table->integer('booking_id')->unsigned();
$table->foreign('booking_id')->references('id')->on('bookings')
->onDelete('cascade');
// The account type to which the sub-booking belongs
$table->integer('account_type_id')->unsigned();
$table->foreign('account_type_id')->references('id')->on('account_types')
->onDelete('restrict');
// If the sub-booking belongs to a project, this project
// isreferenced here.
$table->integer('project_id')->unsigned()->nullable();
$table->foreign('project_id')->references('id')->on('projects')
->onDelete('set null');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('sub_bookings');
}
}