new: migration file to create documents and files table. #5

This commit is contained in:
weichien00
2021-07-03 02:40:17 +08:00
parent a3ce7c14a1
commit aa4bee875c
2 changed files with 81 additions and 0 deletions
@@ -0,0 +1,43 @@
<?php
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateDocumentsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('documents', function (Blueprint $table) {
$table->id();
$table->morphs('owner');
$table->string('document_type');
$table->string('reference');
$table->integer('status')->default(ApprovalStatus::PENDING_VERIFICATION);
$table->timestamp('issued_date')->nullable();
$table->timestamp('expired_date')->nullable();
$table->foreignId('approver')->nullable()->unsigned();
$table->timestamp('approval_date')->nullable();
$table->softDeletes();
$table->timestamps();
$table->foreign('approver')->references('id')->on('users');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('documents');
}
}
@@ -0,0 +1,38 @@
<?php
use App\Classes\ValueObjects\Constants\FileType;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateFilesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('files', function (Blueprint $table) {
$table->id();
$table->foreignId('document_id')->unsigned();
$table->text('file');
$table->string('file_type')->default(FileType::JPEG);
$table->softDeletes();
$table->timestamps();
$table->foreign('document_id')->references('id')->on('documents');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('files');
}
}