1
0
forked from poc/pds

Added foreign and unique key for mfm_meters table

This commit is contained in:
dhanabalan
2025-07-31 16:30:04 +05:30
parent 9a2a6bdd9b
commit bb462a6c45

View File

@@ -0,0 +1,40 @@
<?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'
ALTER TABLE mfm_meters
ADD COLUMN device_master_id BIGINT NOT NULL,
ADD CONSTRAINT mfm_meters_device_master_id_fkey
FOREIGN KEY (device_master_id) REFERENCES device_masters(id);
SQL;
DB::statement($sql);
$sql1 = <<<'SQL'
ALTER TABLE mfm_meters
ADD UNIQUE (plant_id, device_master_id, name);
SQL;
DB::statement($sql1);
}
/**
* Reverse the migrations.
*/
public function down(): void
{
// Schema::table('mfm_meters', function (Blueprint $table) {
// //
// });
}
};