![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/rentpix.corals.io/Corals/modules/RentPix/database/migrations/ |
<?php namespace Corals\Modules\RentPix\database\migrations; use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; class RentPixTables extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('pix_rate_codes', function (Blueprint $table) { $table->increments('id'); $table->string('code')->unique(); $table->string('title'); $this->commonColumns($table); }); Schema::create('pix_units', function (Blueprint $table) { $table->increments('id'); $table->string('code')->unique(); $table->string('vin')->nullable()->index(); $table->string('license')->nullable()->index(); $table->string('engine')->nullable(); $table->string('make')->nullable(); $table->string('model')->nullable(); $table->year('model_year')->nullable(); $table->string('status')->default('active')->index(); $table->string('integration_id')->nullable()->unique(); $table->date('last_inspected_at')->nullable(); $table->string('rate_code')->nullable(); $table->foreign('rate_code') ->references('code') ->on('pix_rate_codes'); $this->commonColumns($table); }); Schema::create('pix_customers', function (Blueprint $table) { $table->increments('id'); $table->string('type')->index(); $table->string('name')->nullable(); $table->string('first_name')->nullable(); $table->string('last_name')->nullable(); $table->text('address')->nullable(); $table->string('city')->nullable(); $table->string('state')->nullable(); $table->string('zip')->nullable(); $table->string('phone')->nullable(); $table->string('email')->nullable(); $table->string('alt_email')->nullable(); $table->string('integration_id')->unique()->nullable(); $this->commonColumns($table); }); Schema::create('pix_reservations', function (Blueprint $table) { $table->increments('id'); $table->string('code')->unique(); $table->string('type')->index(); $table->string('rental_status')->index(); $table->json('start_location'); $table->json('end_location'); $table->string('integration_id')->nullable()->unique(); $table->unsignedInteger('unit_id')->nullable(); $table->foreign('unit_id') ->references('id') ->on('pix_units') ->cascadeOnDelete() ->cascadeOnUpdate(); $table->unsignedInteger('customer_id')->nullable(); $table->foreign('customer_id') ->references('id') ->on('pix_customers') ->cascadeOnDelete() ->cascadeOnUpdate(); $table->timestamp('starts_at'); $table->timestamp('ends_at'); $this->commonColumns($table); }); Schema::create('pix_inspections', function (Blueprint $table) { $table->increments('id'); $table->string('code')->unique(); $table->string('type')->index(); $table->string('status')->index(); $table->dateTime('inspected_at')->nullable(); $table->unsignedInteger('user_id'); $table->foreign('user_id') ->references('id') ->on('users') ->cascadeOnDelete() ->cascadeOnUpdate(); $table->unsignedInteger('reservation_id'); $table->foreign('reservation_id') ->references('id') ->on('pix_reservations') ->cascadeOnDelete() ->cascadeOnUpdate(); $this->commonColumns($table); }); Schema::create('pix_drivers', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->date('dob')->nullable(); $table->string('email')->nullable(); $table->string('phone'); $table->string('address'); $table->string('license'); $table->date('license_expiration_date'); $table->string('integration_id')->nullable()->unique(); $this->commonColumns($table); }); Schema::create('pix_driver_customer', function (Blueprint $table) { $table->increments('id'); $table->unsignedInteger('driver_id'); $table->unsignedInteger('customer_id'); $this->commonColumns($table); $table->foreign('driver_id') ->references('id') ->on('pix_drivers') ->onUpdate('cascade'); $table->foreign('customer_id') ->references('id') ->on('pix_customers') ->onUpdate('cascade'); }); Schema::create('pix_driver_reservation', function (Blueprint $table) { $table->increments('id'); $table->unsignedInteger('driver_id'); $table->unsignedInteger('reservation_id'); $table->boolean('is_primary')->default(false); $this->commonColumns($table); $table->foreign('driver_id') ->references('id') ->on('pix_drivers') ->onUpdate('cascade'); $table->foreign('reservation_id') ->references('id') ->on('pix_reservations') ->onUpdate('cascade'); }); Schema::create('pix_driver_inspection', function (Blueprint $table) { $table->increments('id'); $table->unsignedInteger('driver_id'); $table->unsignedInteger('inspection_id'); $table->boolean('is_primary')->default(false); $this->commonColumns($table); $table->foreign('driver_id') ->references('id') ->on('pix_drivers') ->onUpdate('cascade'); $table->foreign('inspection_id') ->references('id') ->on('pix_inspections') ->onUpdate('cascade'); }); Schema::table('media', function (Blueprint $table) { $table->unsignedInteger('driver_id')->after('collection_name')->nullable(); $table->foreign('driver_id') ->references('id') ->on('pix_drivers') ->cascadeOnUpdate() ->nullOnDelete(); }); Schema::table('users', function (Blueprint $table) { $table->after('remember_token', function ($table) { $table->text('device_token')->nullable(); }); }); Schema::create('pix_failed_inspections', function (Blueprint $table) { $table->increments('id'); $table->string('code')->unique(); $table->json('payload'); $table->text('failure_message')->nullable(); $table->string('status')->index(); $table->unsignedInteger('inspection_id')->nullable(); $this->commonColumns($table); $table->foreign('inspection_id') ->references('id') ->on('pix_inspections') ->onUpdate('cascade'); }); Schema::create('pix_rate_code_photos', function (Blueprint $table) { $table->increments('id'); $table->string('rate_code'); $table->string('photo_lov_code'); $table->boolean('is_required')->default(false); $table->boolean('damage_circle_enabled')->default(false); $table->boolean('exclude')->default(false); $table->foreign('rate_code') ->references('code') ->on('pix_rate_codes') ->onUpdate('cascade'); $table->foreign('photo_lov_code') ->references('code') ->on('utility_list_of_values') ->onUpdate('cascade'); $this->commonColumns($table); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('pix_rate_code_photos'); Schema::dropIfExists('pix_failed_inspections'); Schema::dropIfExists('pix_driver_inspection'); Schema::dropIfExists('pix_driver_reservation'); Schema::dropIfExists('pix_driver_customer'); Schema::dropIfExists('pix_inspections'); Schema::dropIfExists('pix_reservations'); Schema::dropIfExists('pix_customers'); Schema::dropIfExists('pix_units'); Schema::dropIfExists('pix_rate_codes'); Schema::table('media', function (Blueprint $table) { $table->dropForeign('media_driver_id_foreign'); $table->dropColumn('driver_id'); }); Schema::dropIfExists('pix_drivers'); Schema::table('users', function (Blueprint $table) { $table->dropColumn('device_token'); }); } protected function commonColumns(Blueprint $table) { $table->text('properties')->nullable(); $table->auditable(); $table->softDeletes(); $table->timestamps(); } }