GermanAirlinesVA-Fleet/updates/builder_table_create_aircrafts.php

58 lines
1.8 KiB
PHP

<?php namespace GermanAirlinesVa\Fleet\Updates;
use DB;
use Schema;
use October\Rain\Database\Updates\Migration;
class BuilderTableCreateGermanAirlinesVaFleetAircrafts extends Migration
{
public function up()
{
Schema::connection('germanairlinesva_fleet')->create('aircrafts', function ($table) {
$table->engine = 'InnoDB';
$table->bigIncrements('id')->unsigned();
$table->bigInteger('aircraft_type_id')->unsigned();
$table
->foreign('aircraft_type_id')
->references('id')
->on('aircraft_types');
$table->bigInteger('home_airport_id')->unsigned();
$table
->bigInteger('airport_id')
->unsigned()
->nullable();
$table->string('name');
$table->string('registration');
$table->boolean('in_use')->default(true);
$table
->double('total_miles')
->unsigned()
->default(0);
$table
->double('total_fuel')
->unsigned()
->default(0);
$table
->double('total_flight_time')
->unsigned()
->default(0);
$table
->double('total_expenses')
->unsigned()
->default(0);
$table->enum('current_check', ['a', 'b', 'c', 'd'])->nullable();
$table->datetime('last_a_check')->default(DB::raw('NOW()'));
$table->datetime('last_b_check')->default(DB::raw('NOW()'));
$table->datetime('last_c_check')->default(DB::raw('NOW()'));
$table->datetime('last_d_check')->default(DB::raw('NOW()'));
});
}
public function down()
{
Schema::connection('germanairlinesva_fleet')->disableForeignKeyConstraints();
Schema::connection('germanairlinesva_fleet')->dropIfExists('aircrafts');
Schema::connection('germanairlinesva_fleet')->enableForeignKeyConstraints();
}
}