Files
citrus-cms/database/migrations/2025_10_29_123030_create_pdfm_tables.php
T
2026-04-28 21:15:09 +03:00

90 lines
2.9 KiB
PHP

<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreatePdfmTables extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
// PDFM Spools Table
Schema::create('pdfm_spools', function (Blueprint $table) {
$table->id();
$table->string('spool_no')->unique();
$table->string('pdf_file')->nullable();
$table->text('description')->nullable();
$table->timestamps();
});
// PDFM Elements Table
Schema::create('pdfm_elements', function (Blueprint $table) {
$table->id();
$table->string('element_code')->unique();
$table->string('spool_no')->nullable();
$table->string('element_type')->nullable();
$table->text('description')->nullable();
$table->timestamps();
$table->index('spool_no');
});
// PDFM Joints Table
Schema::create('pdfm_joints', function (Blueprint $table) {
$table->id();
$table->string('joint_no')->unique();
$table->string('spool_no')->nullable();
$table->string('element_from')->nullable();
$table->string('element_to')->nullable();
$table->string('joint_type')->nullable();
$table->text('description')->nullable();
$table->timestamps();
$table->index('spool_no');
});
// PDFM Welders Table
Schema::create('pdfm_welders', function (Blueprint $table) {
$table->id();
$table->string('welder_name');
$table->string('welder_code')->unique();
$table->string('qualification')->nullable();
$table->date('qualification_date')->nullable();
$table->date('expiry_date')->nullable();
$table->text('notes')->nullable();
$table->timestamps();
});
// PDFM Welder Assignments Table (many-to-many relationship)
Schema::create('pdfm_welder_assignments', function (Blueprint $table) {
$table->id();
$table->string('joint_no');
$table->unsignedBigInteger('welder_id');
$table->date('assignment_date')->nullable();
$table->timestamps();
$table->foreign('welder_id')->references('id')->on('pdfm_welders')->onDelete('cascade');
$table->index('joint_no');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('pdfm_welder_assignments');
Schema::dropIfExists('pdfm_welders');
Schema::dropIfExists('pdfm_joints');
Schema::dropIfExists('pdfm_elements');
Schema::dropIfExists('pdfm_spools');
}
}