partial update create mutations workflow

This commit is contained in:
2025-06-12 15:10:51 +07:00
parent a5e1348436
commit 1a01efb1b5
33 changed files with 560 additions and 12994 deletions

View File

@@ -0,0 +1,36 @@
<?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
{
/**
* Run the migrations.
*/
public function up(): void
{
// Update existing records yang quantity_approved = 0 menjadi null untuk mutasi yang belum approved
DB::table('mutation_details')
->join('mutations', 'mutations.id', '=', 'mutation_details.mutation_id')
->where('mutation_details.quantity_approved', 0)
->whereNotIn('mutations.status', ['approved', 'completed', 'rejected'])
->update(['mutation_details.quantity_approved' => null]);
Schema::table('mutation_details', function (Blueprint $table) {
$table->decimal('quantity_approved', 15, 2)->nullable()->default(null)->change();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('mutation_details', function (Blueprint $table) {
$table->decimal('quantity_approved', 15, 2)->default(0)->change();
});
}
};