1
0
forked from poc/pds

Create migration for serial_validations table with necessary fields and constraints

This commit is contained in:
dhanabalan
2025-10-03 16:03:08 +05:30
parent 346e1baec0
commit 90e96f8a66

View File

@@ -0,0 +1,61 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
$sql = <<<'SQL'
CREATE TABLE serial_validations (
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
plant_id BIGINT NOT NULL,
sticker_master_id BIGINT NOT NULL,
invoice_number TEXT NOT NULL,
serial_number TEXT DEFAULT NULL,
motor_scanned_status TEXT DEFAULT NULL,
pump_scanned_status TEXT DEFAULT NULL,
capacitor_scanned_status TEXT DEFAULT NULL,
scanned_status_set TEXT DEFAULT NULL,
scanned_status TEXT DEFAULT NULL,
panel_box_supplier TEXT DEFAULT NULL,
panel_box_serial_number TEXT DEFAULT NULL,
load_rate INT NOT NULL DEFAULT (0),
upload_status TEXT NOT NULL DEFAULT 'N',
batch_number TEXT DEFAULT NULL,
quantity INT DEFAULT NULL,
operator_id TEXT DEFAULT NULL,
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
deleted_at TIMESTAMP,
UNIQUE (plant_id, serial_number),
FOREIGN KEY (sticker_master_id) REFERENCES sticker_masters (id),
FOREIGN KEY (plant_id) REFERENCES plants (id)
);
SQL;
DB::statement($sql);
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('serial_validations');
}
};