up
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
// Backfill producto_id in inventario_prendas from la OP relacionada cuando sea NULL
|
||||
DB::statement("UPDATE inventario_prendas ip SET producto_id = op.producto_id FROM orden_produccions op WHERE ip.orden_produccion_id = op.id AND ip.producto_id IS NULL AND op.producto_id IS NOT NULL");
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
// Revertir sólo las asignaciones que coinciden con la OP actual
|
||||
DB::statement("UPDATE inventario_prendas ip SET producto_id = NULL FROM orden_produccions op WHERE ip.orden_produccion_id = op.id AND ip.producto_id = op.producto_id");
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user