Cleaning up database fields, fix types and columns

This commit is contained in:
Nabeel Shahzad
2017-12-12 13:26:08 -06:00
parent e05976a982
commit d634778ed2
13 changed files with 78 additions and 83 deletions

View File

@@ -28,15 +28,9 @@ class Subfleet extends Model
protected $casts = [
'airline_id' => 'integer',
'fuel_type' => 'integer',
];
/**
* Validation rules
*
* @var array
*/
public static $rules = [
'cargo_capacity' => 'double',
'fuel_capacity' => 'double',
'gross_weight' => 'double',
];
public function airline()

View File

@@ -16,7 +16,7 @@ trait HashId
$key = $model->getKeyName();
if (empty($model->{$key})) {
$hashids = new Hashids('', 10);
$hashids = new Hashids('', 12);
$mt = str_replace('.', '', microtime(true));
$id = $hashids->encode($mt);

View File

@@ -19,14 +19,14 @@ class CreateUsersTable extends Migration
$table->string('email')->unique();
$table->string('password');
$table->string('apikey', 40)->nullable();
$table->integer('airline_id')->nullable()->unsigned();
$table->integer('rank_id')->nullable()->unsigned();
$table->unsignedInteger('airline_id')->unsigned();
$table->unsignedInteger('rank_id')->unsigned();
$table->string('home_airport_id', 5)->nullable();
$table->string('curr_airport_id', 5)->nullable();
$table->string('last_pirep_id')->nullable();
$table->bigInteger('flights')->unsigned()->default(0);
$table->bigInteger('flight_time')->unsigned()->default(0);
$table->decimal('balance', 19, 2)->nullable();
$table->string('last_pirep_id', 12)->nullable();
$table->unsignedBigInteger('flights')->default(0);
$table->unsignedBigInteger('flight_time')->default(0);
$table->decimal('balance', 19)->nullable();
$table->string('timezone', 64)->nullable();
$table->boolean('active')->nullable();
$table->rememberToken();
@@ -48,8 +48,8 @@ class CreateUsersTable extends Migration
// Create table for associating roles to users (Many-to-Many)
Schema::create('role_user', function (Blueprint $table) {
$table->integer('user_id')->unsigned();
$table->integer('role_id')->unsigned();
$table->unsignedInteger('user_id');
$table->unsignedInteger('role_id');
$table->foreign('user_id')->references('id')->on('users')
->onUpdate('cascade')->onDelete('cascade');
@@ -71,8 +71,8 @@ class CreateUsersTable extends Migration
// Create table for associating permissions to roles (Many-to-Many)
Schema::create('permission_role', function (Blueprint $table) {
$table->integer('permission_id')->unsigned();
$table->integer('role_id')->unsigned();
$table->unsignedInteger('permission_id');
$table->unsignedInteger('role_id');
$table->foreign('permission_id')->references('id')->on('permissions')
->onUpdate('cascade')->onDelete('cascade');

View File

@@ -16,7 +16,7 @@ class CreateAirlinesTable extends Migration
Schema::create('airlines', function (Blueprint $table) {
$table->increments('id');
$table->string('icao', 5);
$table->string('iata', 3)->nullable();
$table->string('iata', 5)->nullable();
$table->string('name', 50);
$table->string('country', 2)->nullable();
$table->string('logo', 255)->nullable();

View File

@@ -9,7 +9,7 @@ class CreateAircraftsTable extends Migration
{
Schema::create('aircraft', function (Blueprint $table) {
$table->increments('id');
$table->integer('subfleet_id')->unsigned();
$table->unsignedInteger('subfleet_id');
$table->string('airport_id', 5)->nullable();
$table->string('hex_code', 10)->nullable();
$table->string('name', 50);

View File

@@ -14,12 +14,12 @@ class CreateFaresTable extends Migration
public function up()
{
Schema::create('fares', function (Blueprint $table) {
$table->bigIncrements('id');
$table->increments('id');
$table->string('code', 50);
$table->string('name', 50);
$table->decimal('price', 19, 2)->default(0.0);
$table->decimal('cost', 19, 2)->default(0.0);
$table->integer('capacity')->default(0)->unsigned();
$table->unsignedDecimal('price', 19)->default(0.00);
$table->unsignedDecimal('cost', 19)->default(0.00);
$table->unsignedInteger('capacity')->default(0);
$table->string('notes')->nullable();
$table->boolean('active')->default(true);
$table->timestamps();

View File

@@ -15,9 +15,9 @@ class CreateAirportsTable extends Migration
$table->string('location', 100)->nullable();
$table->string('country', 48)->nullable();
$table->string('tz', 64)->nullable();
$table->double('fuel_100ll_cost', 19, 2)->default(0);
$table->double('fuel_jeta_cost', 19, 2)->default(0);
$table->double('fuel_mogas_cost', 19, 2)->default(0);
$table->unsignedDecimal('fuel_100ll_cost', 19)->default(0);
$table->unsignedDecimal('fuel_jeta_cost', 19)->default(0);
$table->unsignedDecimal('fuel_mogas_cost', 19)->default(0);
$table->float('lat', 7, 4)->default(0.0)->nullable();
$table->float('lon', 7, 4)->default(0.0)->nullable();
});

View File

@@ -14,8 +14,8 @@ class CreateFlightTables extends Migration
public function up()
{
Schema::create('flights', function (Blueprint $table) {
$table->uuid('id');
$table->integer('airline_id')->unsigned();
$table->string('id', 12);
$table->unsignedInteger('airline_id');
$table->string('flight_number', 10);
$table->string('route_code', 5)->nullable();
$table->string('route_leg', 5)->nullable();
@@ -23,9 +23,9 @@ class CreateFlightTables extends Migration
$table->string('arr_airport_id', 5);
$table->string('alt_airport_id', 5)->nullable();
$table->text('route')->nullable();
$table->text('dpt_time', 10)->nullable();
$table->text('arr_time', 10)->nullable();
$table->double('flight_time', 19, 2)->unsigned()->nullable();
$table->string('dpt_time', 10)->nullable();
$table->string('arr_time', 10)->nullable();
$table->unsignedDecimal('flight_time', 19)->nullable();
$table->text('notes')->nullable();
$table->boolean('active')->default(true);
$table->timestamps();
@@ -40,13 +40,14 @@ class CreateFlightTables extends Migration
});
Schema::create('flight_fields', function (Blueprint $table) {
$table->bigIncrements('id');
$table->uuid('flight_id');
$table->increments('id');
$table->string('flight_id', 12);
$table->string('name', 50);
$table->text('value');
$table->timestamps();
});
$table->index('flight_id');
});
}
/**

View File

@@ -16,7 +16,7 @@ class CreateRanksTable extends Migration
Schema::create('ranks', function (Blueprint $table) {
$table->increments('id');
$table->string('name', 50);
$table->integer('hours')->default(0);
$table->unsignedInteger('hours')->default(0);
$table->boolean('auto_approve_acars')->default(false);
$table->boolean('auto_approve_manual')->default(false);
$table->boolean('auto_promote')->default(true);

View File

@@ -14,31 +14,31 @@ class CreateSubfleetTables extends Migration
public function up()
{
Schema::create('subfleets', function (Blueprint $table) {
$table->bigIncrements('id');
$table->integer('airline_id')->unsigned()->nullable();
$table->increments('id');
$table->unsignedInteger('airline_id')->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->unsignedTinyInteger('fuel_type')->nullable();
$table->unsignedDecimal('cargo_capacity', 19)->nullable();
$table->unsignedDecimal('fuel_capacity', 19)->nullable();
$table->unsignedDecimal('gross_weight', 19)->nullable();
$table->timestamps();
});
Schema::create('subfleet_expenses', function(Blueprint $table) {
$table->integer('subfleet_id')->unsigned();
$table->unsignedBigInteger('subfleet_id');
$table->string('name', 50);
$table->decimal('cost', 19, 2)->unsigned();
$table->unsignedDecimal('cost', 19);
$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->unsignedInteger('subfleet_id');
$table->unsignedInteger('fare_id');
$table->unsignedDecimal('price', 19)->nullable();
$table->unsignedDecimal('cost', 19)->nullable();
$table->unsignedInteger('capacity')->nullable();
$table->timestamps();
$table->primary(['subfleet_id', 'fare_id']);
@@ -46,18 +46,18 @@ class CreateSubfleetTables extends Migration
});
Schema::create('subfleet_flight', function(Blueprint $table) {
$table->integer('subfleet_id')->unsigned();
$table->uuid('flight_id');
$table->unsignedInteger('subfleet_id');
$table->string('flight_id', 12);
$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->unsignedInteger('rank_id');
$table->unsignedInteger('subfleet_id');
$table->unsignedDecimal('acars_pay', 19)->nullable();
$table->unsignedDecimal('manual_pay', 19)->nullable();
$table->primary(['rank_id', 'subfleet_id']);
$table->index(['subfleet_id', 'rank_id']);

View File

@@ -14,23 +14,23 @@ class CreatePirepTables extends Migration
public function up()
{
Schema::create('pireps', function (Blueprint $table) {
$table->uuid('id');
$table->integer('user_id')->unsigned();
$table->integer('airline_id')->unsigned();
$table->integer('aircraft_id')->nullable();
$table->string('id', 12);
$table->unsignedInteger('user_id');
$table->unsignedInteger('airline_id');
$table->unsignedInteger('aircraft_id')->nullable();
$table->uuid('flight_id')->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->double('flight_time', 19, 2)->unsigned();
$table->double('gross_weight', 19, 2)->nullable();
$table->double('fuel_used', 19, 2)->nullable();
$table->unsignedDecimal('flight_time', 19);
$table->unsignedDecimal('gross_weight', 19)->nullable();
$table->unsignedDecimal('fuel_used', 19)->nullable();
$table->string('route')->nullable();
$table->string('notes')->nullable();
$table->tinyInteger('source')->default(0);
$table->tinyInteger('status')->default(0);
$table->unsignedTinyInteger('source')->default(0);
$table->unsignedTinyInteger('status')->default(0);
$table->longText('raw_data')->nullable();
$table->timestamps();
$table->softDeletes();
@@ -44,16 +44,16 @@ class CreatePirepTables extends Migration
Schema::create('pirep_comments', function (Blueprint $table) {
$table->bigIncrements('id');
$table->uuid('pirep_id');
$table->bigInteger('user_id', false, true);
$table->string('pirep_id', 12);
$table->unsignedInteger('user_id');
$table->text('comment');
$table->timestamps();
});
Schema::create('pirep_events', function(Blueprint $table) {
$table->bigIncrements('id')->unsigned();
$table->uuid('pirep_id');
$table->string('event');
$table->bigIncrements('id');
$table->string('pirep_id', 12);
$table->string('event', 64);
$table->dateTime('dt');
});
@@ -62,7 +62,7 @@ class CreatePirepTables extends Migration
*/
Schema::create('pirep_expenses', function (Blueprint $table) {
$table->bigIncrements('id');
$table->uuid('pirep_id');
$table->string('pirep_id', 12);
$table->string('name');
$table->double('value', 19, 2)->nullable();
@@ -71,9 +71,9 @@ class CreatePirepTables extends Migration
Schema::create('pirep_fares', function (Blueprint $table) {
$table->bigIncrements('id');
$table->uuid('pirep_id');
$table->string('pirep_id', 12);
$table->unsignedBigInteger('fare_id');
$table->double('count', 19, 2)->nullable();
$table->unsignedInteger('count')->nullable();
$table->index('pirep_id');
});
@@ -84,15 +84,15 @@ class CreatePirepTables extends Migration
Schema::create('pirep_fields', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name', 50);
$table->integer('required');
$table->boolean('required')->default(false);
$table->timestamps();
});
Schema::create('pirep_field_values', function (Blueprint $table) {
$table->bigIncrements('id');
$table->uuid('pirep_id');
$table->string('pirep_id', 12);
$table->string('name', 50);
$table->text('value');
$table->string('value')->nullable();
$table->string('source')->nullable();
$table->timestamps();

View File

@@ -14,14 +14,14 @@ class CreateSettingsTable extends Migration
{
Schema::create('settings', function (Blueprint $table) {
$table->increments('id');
$table->integer('order')->default(1);
$table->unsignedInteger('order')->default(1);
$table->string('name');
$table->string('key');
$table->string('value');
$table->string('group')->nullable();
$table->text('type')->nullable();
$table->text('options')->nullable();
$table->text('description')->nullable();
$table->string('type')->nullable();
$table->string('options')->nullable();
$table->string('description')->nullable();
$table->timestamps();
$table->unique('key');
});

View File

@@ -15,8 +15,8 @@ class CreateBidsTable extends Migration
{
Schema::create('user_bids', function (Blueprint $table) {
$table->increments('id');
$table->integer('user_id', false, true);
$table->uuid('flight_id');
$table->unsignedInteger('user_id');
$table->string('flight_id', 12);
$table->timestamps();
$table->index('user_id');