From b9d49a4af9380623284b26921abccb8cb14bd9f9 Mon Sep 17 00:00:00 2001 From: Nabeel Shahzad Date: Thu, 22 Jun 2017 21:44:49 -0500 Subject: [PATCH] #34 uuid use --- .../migrations/2017_06_08_0000_create_users_table.php | 9 ++++++--- .../2017_06_10_040335_create_fares_table.php | 4 +++- .../2017_06_17_214650_create_flights_table.php | 10 +++++++--- .../2017_06_23_011011_create_subfleets_table.php | 5 +++-- database/seeds/dev.yml | 3 ++- 5 files changed, 21 insertions(+), 10 deletions(-) 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 fe88d606..38a0006f 100755 --- a/database/migrations/2017_06_08_0000_create_users_table.php +++ b/database/migrations/2017_06_08_0000_create_users_table.php @@ -14,7 +14,7 @@ class CreateUsersTable extends Migration public function up() { Schema::create('users', function (Blueprint $table) { - $table->increments('id'); + $table->uuid('id'); $table->string('name')->nullable(); $table->string('email')->unique(); $table->string('password'); @@ -22,7 +22,7 @@ class CreateUsersTable extends Migration $table->integer('rank_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->uuid('last_pirep_id')->nullable(); $table->bigInteger('flights')->nullable()->unsigned(); $table->bigInteger('flight_time')->nullable()->unsigned(); $table->decimal('balance', 19, 2)->nullable(); @@ -31,6 +31,8 @@ class CreateUsersTable extends Migration $table->rememberToken(); $table->timestamps(); $table->softDeletes(); + + $table->primary('id'); }); // Create table for storing roles @@ -44,7 +46,7 @@ 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->uuid('user_id'); $table->integer('role_id')->unsigned(); $table->foreign('user_id')->references('id')->on('users') @@ -53,6 +55,7 @@ class CreateUsersTable extends Migration ->onUpdate('cascade')->onDelete('cascade'); $table->primary(['user_id', 'role_id']); + $table->index(['role_id', 'user_id']); }); // Create table for storing permissions 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 4904a6f6..68369248 100644 --- a/database/migrations/2017_06_10_040335_create_fares_table.php +++ b/database/migrations/2017_06_10_040335_create_fares_table.php @@ -26,13 +26,15 @@ class CreateFaresTable extends Migration }); Schema::create('aircraft_fare', function (Blueprint $table) { - $table->increments('id'); $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->primary(['aircraft_id', 'fare_id']); + $table->index(['fare_id', 'aircraft_id']); }); } 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 e686d849..0b708531 100644 --- a/database/migrations/2017_06_17_214650_create_flights_table.php +++ b/database/migrations/2017_06_17_214650_create_flights_table.php @@ -14,7 +14,7 @@ class CreateFlightsTable extends Migration public function up() { Schema::create('flights', function (Blueprint $table) { - $table->increments('id'); + $table->uuid('id'); $table->integer('airline_id')->unsigned(); $table->text('flight_number'); $table->text('route_code')->nullable(); @@ -29,6 +29,8 @@ class CreateFlightsTable extends Migration $table->boolean('active')->default(true); $table->timestamps(); + $table->primary('id'); + $table->unique('flight_number'); $table->index('flight_number'); @@ -37,9 +39,11 @@ class CreateFlightsTable extends Migration }); Schema::create('flight_aircraft', function ($table) { - $table->increments('id'); - $table->integer('flight_id')->unsigned(); + $table->uuid('flight_id'); $table->integer('aircraft_id')->unsigned(); + + $table->primary(['flight_id', 'aircraft_id']); + $table->index(['aircraft_id', 'flight_id']); }); } diff --git a/database/migrations/2017_06_23_011011_create_subfleets_table.php b/database/migrations/2017_06_23_011011_create_subfleets_table.php index ce6929d5..1b5a39fb 100644 --- a/database/migrations/2017_06_23_011011_create_subfleets_table.php +++ b/database/migrations/2017_06_23_011011_create_subfleets_table.php @@ -23,12 +23,13 @@ class CreateSubfleetsTable extends Migration }); Schema::create('subfleet_rank', function(Blueprint $table) { - $table->increments('id'); - $table->integer('subfleet_id')->unsigned()->nullable(); $table->integer('rank_id')->unsigned()->nullable(); + $table->integer('subfleet_id')->unsigned()->nullable(); $table->double('acars_pay', 19, 2)->unsigned()->nullable(); $table->double('manual_pay', 19, 2)->unsigned()->nullable(); + $table->primary(['rank_id', 'subfleet_id']); + $table->index(['subfleet_id', 'rank_id']); }); } diff --git a/database/seeds/dev.yml b/database/seeds/dev.yml index acce8646..14c92581 100644 --- a/database/seeds/dev.yml +++ b/database/seeds/dev.yml @@ -132,7 +132,8 @@ aircraft_fare: capacity: 10 flights: - - airline_id: 1 + - id: 1 + airline_id: 1 flight_number: 100 dpt_airport_id: 1 arr_airport_id: 2