contract template db design

This commit is contained in:
glovetleong
2021-06-25 22:14:19 +08:00
parent 881c442f68
commit c07faf92a8
11 changed files with 230 additions and 2 deletions
@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateContractTemplatesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('contract_templates', function (Blueprint $table) {
$table->id();
$table->bigInteger('user_id')->unsigned()->nullable();
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$table->string('name');
$table->integer('complete_day_range')->nullable()->default(1);
$table->integer('status')->nullable()->default(1);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('contract_templates');
}
}
@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateContractTemplateLogsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('contract_template_logs', function (Blueprint $table) {
$table->id();
$table->bigInteger('contract_template_id')->unsigned()->nullable();
$table->foreign('contract_template_id')->references('id')->on('contract_templates')->onDelete('cascade');
$table->json('history')->nullable();
$table->text('remark')->nullable();
$table->integer('status')->nullable()->default(1);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('contract_template_logs');
}
}
@@ -0,0 +1,42 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateContractTemplateObligationsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('contract_template_obligations', function (Blueprint $table) {
$table->id();
$table->bigInteger('user_id')->unsigned()->nullable();
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$table->bigInteger('contract_template_id')->unsigned()->nullable();
$table->foreign('contract_template_id')->references('id')->on('contract_templates')->onDelete('cascade');
$table->float('sequence', 4, 2)->nullable();
$table->string('reference');
$table->json('content');
$table->integer('must_complete')->nullable()->default(1);
$table->integer('must_accept')->nullable()->default(1);
$table->integer('complete_day_range')->nullable()->default(1);
$table->integer('status')->nullable()->default(1);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('contract_template_obligations');
}
}
@@ -0,0 +1,38 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateContractTemplateObligationDependenciesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('contract_template_obligation_dependencies', function (Blueprint $table) {
$table->id();
$table->bigInteger('user_id')->unsigned()->nullable();
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$table->bigInteger('contract_template_obligation_id')->unsigned()->nullable();
$table->foreign('contract_template_obligation_id', 'ctod_cto_id')->references('id')->on('contract_template_obligations')->onDelete('cascade');
$table->bigInteger('depend_template_contract_obligation_id')->unsigned()->nullable();
$table->foreign('depend_template_contract_obligation_id', 'dctod_cto_id')->references('id')->on('contract_template_obligations')->onDelete('cascade');
$table->integer('status')->nullable()->default(1);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('contract_template_obligation_dependencies');
}
}
@@ -17,6 +17,10 @@ class CreateContractsTable extends Migration
$table->id();
$table->bigInteger('user_id')->unsigned()->nullable();
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$table->bigInteger('contract_template_id')->unsigned()->nullable();
$table->foreign('contract_template_id')->references('id')->on('contract_templates')->onDelete('cascade');
$table->string('name');
$table->json('in_time_contract_template');
$table->integer('status')->nullable()->default(1);
$table->timestamp('completed_at')->nullable();
$table->timestamp('failed_at')->nullable();
@@ -20,7 +20,7 @@ class CreateContractObligationDependenciesTable extends Migration
$table->bigInteger('contract_obligation_id')->unsigned()->nullable();
$table->foreign('contract_obligation_id')->references('id')->on('contract_obligations')->onDelete('cascade');
$table->bigInteger('depend_contract_obligation_id')->unsigned()->nullable();
$table->foreign('depend_contract_obligation_id')->references('id')->on('contract_obligations')->onDelete('cascade');
$table->foreign('depend_contract_obligation_id', 'cod_dco_id')->references('id')->on('contract_obligations')->onDelete('cascade');
$table->integer('status')->nullable()->default(1);
$table->timestamps();
});