From 381a713882233ef65be54182ace77bd37118cc53 Mon Sep 17 00:00:00 2001 From: Nabeel Shahzad Date: Wed, 21 Jun 2017 11:40:08 -0500 Subject: [PATCH] more schema adjustments to tighten up column types and constraints --- app/Models/Aircraft.php | 3 --- app/Models/AircraftClass.php | 2 -- app/Models/Airline.php | 3 --- app/Models/Airport.php | 3 --- app/Models/Fare.php | 3 --- app/Models/Flight.php | 3 --- app/Models/User.php | 1 + .../2017_06_08_0000_create_users_table.php | 20 +++++++++---------- ...017_06_08_191703_create_airlines_table.php | 1 - ...17_06_09_010621_create_aircrafts_table.php | 2 -- .../2017_06_10_040335_create_fares_table.php | 18 ++++++++--------- ...017_06_11_135707_create_airports_table.php | 1 - ...2017_06_17_214650_create_flights_table.php | 2 -- 13 files changed, 19 insertions(+), 43 deletions(-) diff --git a/app/Models/Aircraft.php b/app/Models/Aircraft.php index 0a96d77f..b1fa60fe 100644 --- a/app/Models/Aircraft.php +++ b/app/Models/Aircraft.php @@ -3,7 +3,6 @@ namespace App\Models; use Eloquent as Model; -use Illuminate\Database\Eloquent\SoftDeletes; /** * Class Aircraft @@ -13,8 +12,6 @@ use Illuminate\Database\Eloquent\SoftDeletes; */ class Aircraft extends Model { - use SoftDeletes; - public $table = 'aircraft'; protected $dates = ['deleted_at']; diff --git a/app/Models/AircraftClass.php b/app/Models/AircraftClass.php index 4afd5373..ebe2f7bf 100644 --- a/app/Models/AircraftClass.php +++ b/app/Models/AircraftClass.php @@ -12,8 +12,6 @@ use Illuminate\Database\Eloquent\SoftDeletes; */ class AircraftClass extends Model { - //use SoftDeletes; - public $table = 'aircraft_classes'; protected $dates = ['deleted_at']; diff --git a/app/Models/Airline.php b/app/Models/Airline.php index 842b2019..9995a2f5 100644 --- a/app/Models/Airline.php +++ b/app/Models/Airline.php @@ -3,7 +3,6 @@ namespace App\Models; use Eloquent as Model; -use Illuminate\Database\Eloquent\SoftDeletes; /** * Class Airline @@ -11,8 +10,6 @@ use Illuminate\Database\Eloquent\SoftDeletes; */ class Airline extends Model { - use SoftDeletes; - public $table = 'airlines'; protected $dates = ['deleted_at']; diff --git a/app/Models/Airport.php b/app/Models/Airport.php index 732171b6..923b6d34 100644 --- a/app/Models/Airport.php +++ b/app/Models/Airport.php @@ -3,7 +3,6 @@ namespace App\Models; use Eloquent as Model; -use Illuminate\Database\Eloquent\SoftDeletes; /** * Class Airport @@ -11,8 +10,6 @@ use Illuminate\Database\Eloquent\SoftDeletes; */ class Airport extends Model { - use SoftDeletes; - public $table = 'airports'; diff --git a/app/Models/Fare.php b/app/Models/Fare.php index 54685c69..3d5152b2 100644 --- a/app/Models/Fare.php +++ b/app/Models/Fare.php @@ -3,7 +3,6 @@ namespace App\Models; use Eloquent as Model; -use Illuminate\Database\Eloquent\SoftDeletes; /** * Class Fare @@ -13,8 +12,6 @@ use Illuminate\Database\Eloquent\SoftDeletes; */ class Fare extends Model { - use SoftDeletes; - public $table = 'fares'; protected $dates = ['deleted_at']; diff --git a/app/Models/Flight.php b/app/Models/Flight.php index db92f337..0f172feb 100644 --- a/app/Models/Flight.php +++ b/app/Models/Flight.php @@ -3,7 +3,6 @@ namespace App\Models; use Eloquent as Model; -use Illuminate\Database\Eloquent\SoftDeletes; /** * Class Flight @@ -12,8 +11,6 @@ use Illuminate\Database\Eloquent\SoftDeletes; */ class Flight extends Model { - use SoftDeletes; - public $table = 'flights'; protected $dates = ['deleted_at']; diff --git a/app/Models/User.php b/app/Models/User.php index d8dbdde1..f2776cbd 100755 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -5,6 +5,7 @@ namespace App\Models; use Illuminate\Notifications\Notifiable; use Illuminate\Foundation\Auth\User as Authenticatable; use Zizaco\Entrust\Traits\EntrustUserTrait; +use Illuminate\Database\Eloquent\SoftDeletes; /** * App\User diff --git a/database/migrations/2017_06_08_0000_create_users_table.php b/database/migrations/2017_06_08_0000_create_users_table.php index c62881d8..3a5ff54e 100755 --- a/database/migrations/2017_06_08_0000_create_users_table.php +++ b/database/migrations/2017_06_08_0000_create_users_table.php @@ -18,18 +18,18 @@ class CreateUsersTable extends Migration $table->string('name')->nullable(); $table->string('email')->unique(); $table->string('password'); - $table->string('code')->nullable(); - $table->string('location')->nullable(); - $table->string('hub')->nullable(); - $table->unsignedBigInteger('flights')->nullable(); - $table->float('hours')->nullable(); - $table->float('pay')->nullable(); - $table->boolean('confirmed')->nullable(); - $table->boolean('retired')->nullable(); - $table->dateTime('last_pirep')->nullable(); - $table->integer('timezone')->default(0); + $table->integer('airline_id')->nullable()->unsigned(); + $table->integer('home_airport_id')->nullable()->unsigned(); + $table->integer('curr_airport_id')->nullable()->unsigned(); + $table->bigInteger('last_pirep_id')->nullable()->unsigned(); + $table->bigInteger('flights')->nullable()->unsigned(); + $table->bigInteger('flight_time')->nullable()->unsigned(); + $table->decimal('balance', 19, 2)->nullable(); + $table->tinyInteger('timezone')->default(0); + $table->boolean('active')->nullable(); $table->rememberToken(); $table->timestamps(); + $table->softDeletes(); }); // Create table for storing roles diff --git a/database/migrations/2017_06_08_191703_create_airlines_table.php b/database/migrations/2017_06_08_191703_create_airlines_table.php index e3d7d9d2..192fa89b 100644 --- a/database/migrations/2017_06_08_191703_create_airlines_table.php +++ b/database/migrations/2017_06_08_191703_create_airlines_table.php @@ -19,7 +19,6 @@ class CreateAirlinesTable extends Migration $table->string('name'); $table->boolean('active'); $table->timestamps(); - $table->softDeletes(); $table->index('code'); $table->unique('code'); diff --git a/database/migrations/2017_06_09_010621_create_aircrafts_table.php b/database/migrations/2017_06_09_010621_create_aircrafts_table.php index d16dee6d..e371883f 100644 --- a/database/migrations/2017_06_09_010621_create_aircrafts_table.php +++ b/database/migrations/2017_06_09_010621_create_aircrafts_table.php @@ -18,7 +18,6 @@ class CreateAircraftsTable extends Migration $table->string('fuel_capacity')->nullable(); $table->boolean('active')->default(true); $table->timestamps(); - $table->softDeletes(); $table->index('icao'); $table->unique('registration'); @@ -30,7 +29,6 @@ class CreateAircraftsTable extends Migration $table->string('name'); $table->string('notes')->nullable(); $table->timestamps(); - $table->softDeletes(); $table->index('code'); }); diff --git a/database/migrations/2017_06_10_040335_create_fares_table.php b/database/migrations/2017_06_10_040335_create_fares_table.php index e832a3a5..4904a6f6 100644 --- a/database/migrations/2017_06_10_040335_create_fares_table.php +++ b/database/migrations/2017_06_10_040335_create_fares_table.php @@ -17,24 +17,22 @@ class CreateFaresTable extends Migration $table->increments('id'); $table->string('code'); $table->string('name'); - $table->float('price')->default(0.0); - $table->float('cost')->default(0.0); - $table->integer('capacity')->default(0); + $table->decimal('price', 19, 2)->default(0.0); + $table->decimal('cost', 19, 2)->default(0.0); + $table->integer('capacity')->default(0)->unsigned(); $table->string('notes')->nullable(); $table->boolean('active')->default(true); $table->timestamps(); - $table->softDeletes(); }); Schema::create('aircraft_fare', function (Blueprint $table) { $table->increments('id'); - $table->integer('aircraft_id'); - $table->integer('fare_id'); - $table->float('price')->nullable(); - $table->float('cost')->nullable(); - $table->integer('capacity')->nullable(); + $table->integer('aircraft_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->timestamps(); - $table->softDeletes(); }); } diff --git a/database/migrations/2017_06_11_135707_create_airports_table.php b/database/migrations/2017_06_11_135707_create_airports_table.php index e44f6854..60281c7d 100644 --- a/database/migrations/2017_06_11_135707_create_airports_table.php +++ b/database/migrations/2017_06_11_135707_create_airports_table.php @@ -22,7 +22,6 @@ class CreateAirportsTable extends Migration $table->float('lat', 7, 4)->default(0.0); $table->float('lon', 7, 4)->default(0.0); $table->timestamps(); - $table->softDeletes(); $table->index('icao'); }); diff --git a/database/migrations/2017_06_17_214650_create_flights_table.php b/database/migrations/2017_06_17_214650_create_flights_table.php index 8930353d..e686d849 100644 --- a/database/migrations/2017_06_17_214650_create_flights_table.php +++ b/database/migrations/2017_06_17_214650_create_flights_table.php @@ -28,7 +28,6 @@ class CreateFlightsTable extends Migration $table->text('notes')->nullable(); $table->boolean('active')->default(true); $table->timestamps(); - $table->softDeletes(); $table->unique('flight_number'); @@ -41,7 +40,6 @@ class CreateFlightsTable extends Migration $table->increments('id'); $table->integer('flight_id')->unsigned(); $table->integer('aircraft_id')->unsigned(); - }); }