Remove subfleet_expenses and combine into main expenses table; select expense type on subfleet #130 #136

This commit is contained in:
Nabeel Shahzad
2018-03-05 21:24:49 -06:00
parent 8c05ad134e
commit 88a8fd2bbd
20 changed files with 160 additions and 138 deletions

View File

@@ -3,14 +3,11 @@
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
/**
* Class CreateSubfleetTables
*/
class CreateSubfleetTables extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('subfleets', function (Blueprint $table) {
@@ -26,17 +23,6 @@ class CreateSubfleetTables extends Migration
$table->timestamps();
});
Schema::create('subfleet_expenses', function(Blueprint $table) {
$table->increments('id');
$table->unsignedBigInteger('subfleet_id');
$table->string('name', 50);
$table->unsignedTinyInteger('type'); # ExpenseType
$table->unsignedDecimal('amount');
$table->timestamps();
$table->index('subfleet_id');
});
Schema::create('subfleet_fare', function (Blueprint $table) {
$table->unsignedInteger('subfleet_id');
$table->unsignedInteger('fare_id');
@@ -76,7 +62,6 @@ class CreateSubfleetTables extends Migration
public function down()
{
Schema::dropIfExists('subfleets');
Schema::dropIfExists('subfleet_expenses');
Schema::dropIfExists('subfleet_fare');
Schema::dropIfExists('subfleet_flight');
Schema::dropIfExists('subfleet_rank');

View File

@@ -16,15 +16,19 @@ class CreateExpensesTable extends Migration
Schema::create('expenses', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('airline_id')->nullable();
$table->string('name');
$table->unsignedInteger('amount');
$table->unsignedTinyInteger('type');
$table->boolean('multiplier')->nullable()->default(0);
$table->boolean('active')->nullable()->default(true);
# Internal fields are expenses tied to some system object
# ref fields are expenses tied to some model object
# EG, the airports has an internal expense for gate costs
$table->nullableMorphs('expensable');
$table->string('ref_class')->nullable();
$table->string('ref_class_id', 36)->nullable();
$table->index(['ref_class', 'ref_class_id']);
$table->timestamps();
});
}