partial update create mutations workflow
This commit is contained in:
@@ -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();
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user