phpvms/database/migrations/2017_06_23_011011_create_subfleet_tables.php
2017-12-12 11:57:52 -06:00

81 lines
2.7 KiB
PHP

<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateSubfleetTables extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('subfleets', function (Blueprint $table) {
$table->bigIncrements('id');
$table->integer('airline_id')->unsigned()->nullable();
$table->string('name', 50);
$table->string('type', 7);
$table->tinyInteger('fuel_type')->unsigned()->nullable();
$table->double('cargo_capacity', 19, 2)->nullable();
$table->double('fuel_capacity', 19, 2)->nullable();
$table->double('gross_weight', 19, 2)->nullable();
$table->timestamps();
});
Schema::create('subfleet_expenses', function(Blueprint $table) {
$table->integer('subfleet_id')->unsigned();
$table->string('name', 50);
$table->decimal('cost', 19, 2)->unsigned();
$table->primary(['subfleet_id', 'name']);
});
Schema::create('subfleet_fare', function (Blueprint $table) {
$table->integer('subfleet_id')->unsigned();
$table->integer('fare_id')->unsigned();
$table->decimal('price', 19, 2)->nullable();
$table->decimal('cost', 19, 2)->nullable();
$table->integer('capacity')->nullable()->unsigned();
$table->timestamps();
$table->primary(['subfleet_id', 'fare_id']);
$table->index(['fare_id', 'subfleet_id']);
});
Schema::create('subfleet_flight', function(Blueprint $table) {
$table->integer('subfleet_id')->unsigned();
$table->uuid('flight_id');
$table->primary(['subfleet_id', 'flight_id']);
$table->index(['flight_id', 'subfleet_id']);
});
Schema::create('subfleet_rank', function(Blueprint $table) {
$table->integer('rank_id')->unsigned();
$table->integer('subfleet_id')->unsigned();
$table->double('acars_pay', 19, 2)->unsigned()->nullable();
$table->double('manual_pay', 19, 2)->unsigned()->nullable();
$table->primary(['rank_id', 'subfleet_id']);
$table->index(['subfleet_id', 'rank_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('subfleets');
Schema::dropIfExists('subfleet_expenses');
Schema::dropIfExists('subfleet_fare');
Schema::dropIfExists('subfleet_flight');
Schema::dropIfExists('subfleet_rank');
}
}