2017-06-29 08:54:05 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use Illuminate\Database\Migrations\Migration;
|
|
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
|
|
|
|
|
|
class CreatePirepsTable extends Migration
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Run the migrations.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function up()
|
|
|
|
{
|
|
|
|
Schema::create('pireps', function (Blueprint $table) {
|
|
|
|
$table->uuid('id');
|
2017-07-23 22:45:33 +08:00
|
|
|
$table->integer('user_id')->unsigned();
|
2017-08-05 09:17:04 +08:00
|
|
|
$table->integer('airline_id')->unsigned();
|
2017-07-23 22:45:33 +08:00
|
|
|
$table->integer('aircraft_id')->nullable();
|
2017-08-24 03:19:05 +08:00
|
|
|
$table->uuid('flight_id')->nullable();
|
|
|
|
$table->string('flight_number', 10)->nullable();
|
2017-07-11 07:54:51 +08:00
|
|
|
$table->string('route_code', 5)->nullable();
|
|
|
|
$table->string('route_leg', 5)->nullable();
|
2017-12-01 10:28:45 +08:00
|
|
|
$table->string('dpt_airport_id', 5)->unsigned();
|
|
|
|
$table->string('arr_airport_id', 5)->unsigned();
|
2017-07-11 07:54:51 +08:00
|
|
|
$table->double('flight_time', 19, 2)->unsigned();
|
2017-07-05 05:45:49 +08:00
|
|
|
$table->double('gross_weight', 19, 2)->nullable();
|
2017-07-11 07:54:51 +08:00
|
|
|
$table->double('fuel_used', 19, 2)->nullable();
|
2017-06-29 08:54:05 +08:00
|
|
|
$table->string('route')->nullable();
|
|
|
|
$table->string('notes')->nullable();
|
2017-07-04 14:05:37 +08:00
|
|
|
$table->tinyInteger('source')->default(0);
|
|
|
|
$table->tinyInteger('status')->default(0);
|
2017-08-17 07:25:55 +08:00
|
|
|
$table->longText('raw_data')->nullable();
|
2017-06-29 08:54:05 +08:00
|
|
|
$table->timestamps();
|
|
|
|
$table->softDeletes();
|
|
|
|
|
|
|
|
$table->primary('id');
|
|
|
|
$table->index('user_id');
|
|
|
|
$table->index('flight_id');
|
|
|
|
$table->index('dpt_airport_id');
|
|
|
|
$table->index('arr_airport_id');
|
|
|
|
});
|
|
|
|
|
2017-08-02 23:17:54 +08:00
|
|
|
Schema::create('pirep_comments', function (Blueprint $table) {
|
2017-08-02 23:20:51 +08:00
|
|
|
$table->bigIncrements('id');
|
2017-08-02 23:17:54 +08:00
|
|
|
$table->uuid('pirep_id');
|
|
|
|
$table->bigInteger('user_id', false, true);
|
|
|
|
$table->text('comment');
|
|
|
|
$table->timestamps();
|
|
|
|
});
|
|
|
|
|
2017-07-24 02:04:50 +08:00
|
|
|
Schema::create('pirep_events', function(Blueprint $table) {
|
|
|
|
$table->bigIncrements('id')->unsigned();
|
|
|
|
$table->uuid('pirep_id');
|
|
|
|
$table->string('event');
|
|
|
|
$table->dateTime('dt');
|
|
|
|
});
|
|
|
|
|
2017-07-05 05:45:49 +08:00
|
|
|
/*
|
|
|
|
* Financial tables/fields
|
|
|
|
*/
|
|
|
|
Schema::create('pirep_expenses', function (Blueprint $table) {
|
2017-08-02 23:20:51 +08:00
|
|
|
$table->bigIncrements('id');
|
2017-07-05 05:45:49 +08:00
|
|
|
$table->uuid('pirep_id');
|
|
|
|
$table->string('name');
|
|
|
|
$table->double('value', 19, 2)->nullable();
|
|
|
|
|
|
|
|
$table->index('pirep_id');
|
|
|
|
});
|
|
|
|
|
|
|
|
Schema::create('pirep_fares', function (Blueprint $table) {
|
2017-08-02 23:20:51 +08:00
|
|
|
$table->bigIncrements('id');
|
2017-07-05 05:45:49 +08:00
|
|
|
$table->uuid('pirep_id');
|
|
|
|
$table->unsignedBigInteger('fare_id');
|
|
|
|
$table->double('count', 19, 2)->nullable();
|
|
|
|
|
|
|
|
$table->index('pirep_id');
|
|
|
|
});
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Additional PIREP data
|
|
|
|
*/
|
2017-06-29 08:54:05 +08:00
|
|
|
Schema::create('pirep_fields', function (Blueprint $table) {
|
2017-08-02 23:20:51 +08:00
|
|
|
$table->bigIncrements('id');
|
2017-07-11 07:54:51 +08:00
|
|
|
$table->string('name', 50);
|
2017-06-29 08:54:05 +08:00
|
|
|
$table->integer('required');
|
|
|
|
$table->timestamps();
|
|
|
|
});
|
|
|
|
|
|
|
|
Schema::create('pirep_field_values', function (Blueprint $table) {
|
2017-08-02 23:20:51 +08:00
|
|
|
$table->bigIncrements('id');
|
2017-06-29 08:54:05 +08:00
|
|
|
$table->uuid('pirep_id');
|
2017-07-11 07:54:51 +08:00
|
|
|
$table->string('name', 50);
|
|
|
|
$table->text('value');
|
2017-07-14 11:09:38 +08:00
|
|
|
$table->string('source')->nullable();
|
2017-06-29 08:54:05 +08:00
|
|
|
$table->timestamps();
|
|
|
|
|
|
|
|
$table->index('pirep_id');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reverse the migrations.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function down()
|
|
|
|
{
|
|
|
|
Schema::drop('pireps');
|
2017-08-02 23:20:51 +08:00
|
|
|
Schema::drop('pirep_comments');
|
2017-07-05 05:45:49 +08:00
|
|
|
Schema::drop('pirep_expenses');
|
|
|
|
Schema::drop('pirep_fares');
|
2017-06-29 08:54:05 +08:00
|
|
|
Schema::drop('pirep_fields');
|
|
|
|
Schema::drop('pirep_field_values');
|
|
|
|
}
|
|
|
|
}
|