phpvms/database/migrations/2017_06_28_195426_create_pirep_tables.php

118 lines
3.8 KiB
PHP
Raw Normal View History

2017-06-29 08:54:05 +08:00
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
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) {
$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();
$table->string('flight_number', 10)->nullable();
$table->string('route_code', 5)->nullable();
$table->string('route_leg', 5)->nullable();
$table->string('dpt_airport_id', 5);
$table->string('arr_airport_id', 5);
$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();
$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');
$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) {
$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');
$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');
$table->string('pirep_id', 12);
2017-07-05 05:45:49 +08:00
$table->unsignedBigInteger('fare_id');
$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');
$table->string('name', 50);
$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');
$table->string('pirep_id', 12);
$table->string('name', 50);
$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()
{
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
}
}