Migration file for orders

This commit is contained in:
Fairuz
2021-07-08 16:30:10 +08:00
parent c3d0cba20c
commit 861341ce3a
6 changed files with 156 additions and 0 deletions
+11
View File
@@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Order extends Model
{
use HasFactory;
}
+11
View File
@@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class OrderRole extends Model
{
use HasFactory;
}
+11
View File
@@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class OrderStep extends Model
{
use HasFactory;
}
@@ -0,0 +1,40 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateOrdersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('orders', function (Blueprint $table) {
$table->id();
$table->integer('company_module_id')->unsigned()->index()->comment('Entity responsible to create this order');
$table->string('reference')->comment('Reference no for user ');
$table->string('reference_contract')->comment('Reference no from Unity platform');
$table->integer('type')->default(0)->comment('Order packages can be shipped in shared or dedicated container');
$table->integer('status')->default(0)->comment('Status of this order, e.g. processing, shipping etc.');
$table->softDeletes();
$table->timestamps();
//Uncomment when foreign key table ready
//$table->foreign('company_module_id')->references('id')->on('company_modules');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('orders');
}
}
@@ -0,0 +1,44 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateOrderStepsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('order_steps', function (Blueprint $table) {
$table->id();
$table->integer('order_id')->unsigned()->index();
$table->integer('appointee_id')->unsigned()->index()->comment('');
$table->string('reference')->comment('Reference no for user ');
$table->integer('primary')->default(0);
$table->decimal('sequence', 4, 2);
$table->integer('status')->default(0)->comment('Status of this order, e.g. processing, shipping etc.');
$table->integer('contract_status')->default(0)->comment('Status of this order, e.g. processing, shipping etc.');
$table->date('complete_date')->nullable();
$table->softDeletes();
$table->timestamps();
//Uncomment when foreign key table ready
//$table->foreign('appointee_id')->references('id')->on('company_modules');
$table->foreign('order_id')->references('id')->on('orders');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('order_steps');
}
}
@@ -0,0 +1,39 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateOrderRolesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('order_roles', function (Blueprint $table) {
$table->id();
$table->integer('order_id')->unsigned()->index()->comment('Order id');
$table->integer('company_module_id')->unsigned()->index()->comment('Entity plays a role in this order, e.g. Freight Forwarder');
$table->integer('role')->default(0)->comment('Describe role participate in processing order');
$table->softDeletes();
$table->timestamps();
//Uncomment when foreign key table ready
//$table->foreign('company_module_id')->references('id')->on('company_modules');
$table->foreign('order_id')->references('id')->on('orders');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('order_roles');
}
}