diff --git a/app/SubBooking.php b/app/SubBooking.php new file mode 100644 index 0000000..f613ee0 --- /dev/null +++ b/app/SubBooking.php @@ -0,0 +1,10 @@ +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'); + } +}