2017-06-29 08:54:05 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use Illuminate\Database\Migrations\Migration;
|
|
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
|
|
|
2017-12-13 01:57:52 +08:00
|
|
|
class CreatePirepTables extends Migration
|
2017-06-29 08:54:05 +08:00
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Run the migrations.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function up()
|
|
|
|
{
|
|
|
|
Schema::create('pireps', function (Blueprint $table) {
|
2017-12-13 03:26:08 +08:00
|
|
|
$table->string('id', 12);
|
|
|
|
$table->unsignedInteger('user_id');
|
|
|
|
$table->unsignedInteger('airline_id');
|
|
|
|
$table->unsignedInteger('aircraft_id')->nullable();
|
2017-12-13 03:33:18 +08:00
|
|
|
$table->string('flight_id', 12)->nullable();
|
2017-08-24 03:19:05 +08:00
|
|
|
$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-02 12:34:59 +08:00
|
|
|
$table->string('dpt_airport_id', 5);
|
|
|
|
$table->string('arr_airport_id', 5);
|
2017-12-13 03:26:08 +08:00
|
|
|
$table->unsignedDecimal('flight_time', 19);
|
|
|
|
$table->unsignedDecimal('gross_weight', 19)->nullable();
|
|
|
|
$table->unsignedDecimal('fuel_used', 19)->nullable();
|
2017-06-29 08:54:05 +08:00
|
|
|
$table->string('route')->nullable();
|
|
|
|
$table->string('notes')->nullable();
|
2017-12-13 03:26:08 +08:00
|
|
|
$table->unsignedTinyInteger('source')->default(0);
|
2017-12-13 03:35:54 +08:00
|
|
|
$table->tinyInteger('status')->default(0); # -1 rejected, 0 pending, 1 accepted
|
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-12-13 03:26:08 +08:00
|
|
|
$table->string('pirep_id', 12);
|
|
|
|
$table->unsignedInteger('user_id');
|
2017-08-02 23:17:54 +08:00
|
|
|
$table->text('comment');
|
|
|
|
$table->timestamps();
|
|
|
|
});
|
|
|
|
|
2017-07-24 02:04:50 +08:00
|
|
|
Schema::create('pirep_events', function(Blueprint $table) {
|
2017-12-13 03:26:08 +08:00
|
|
|
$table->bigIncrements('id');
|
|
|
|
$table->string('pirep_id', 12);
|
|
|
|
$table->string('event', 64);
|
2017-07-24 02:04:50 +08:00
|
|
|
$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-12-13 03:26:08 +08:00
|
|
|
$table->string('pirep_id', 12);
|
2017-07-05 05:45:49 +08:00
|
|
|
$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-12-13 03:26:08 +08:00
|
|
|
$table->string('pirep_id', 12);
|
2017-07-05 05:45:49 +08:00
|
|
|
$table->unsignedBigInteger('fare_id');
|
2017-12-13 03:26:08 +08:00
|
|
|
$table->unsignedInteger('count')->nullable();
|
2017-07-05 05:45:49 +08:00
|
|
|
|
|
|
|
$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-12-13 03:26:08 +08:00
|
|
|
$table->boolean('required')->default(false);
|
2017-06-29 08:54:05 +08:00
|
|
|
$table->timestamps();
|
|
|
|
});
|
|
|
|
|
|
|
|
Schema::create('pirep_field_values', function (Blueprint $table) {
|
2017-08-02 23:20:51 +08:00
|
|
|
$table->bigIncrements('id');
|
2017-12-13 03:26:08 +08:00
|
|
|
$table->string('pirep_id', 12);
|
2017-07-11 07:54:51 +08:00
|
|
|
$table->string('name', 50);
|
2017-12-13 03:26:08 +08:00
|
|
|
$table->string('value')->nullable();
|
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()
|
|
|
|
{
|
2017-12-13 01:49:35 +08:00
|
|
|
Schema::dropIfExists('pireps');
|
|
|
|
Schema::dropIfExists('pirep_comments');
|
|
|
|
Schema::dropIfExists('pirep_expenses');
|
|
|
|
Schema::dropIfExists('pirep_fares');
|
|
|
|
Schema::dropIfExists('pirep_fields');
|
|
|
|
Schema::dropIfExists('pirep_field_values');
|
2017-06-29 08:54:05 +08:00
|
|
|
}
|
|
|
|
}
|