fix some bugs from accounting 9
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* جداسازی اعلان ادمین از اعلان سیستمی (تراکنشها).
|
||||
*/
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
if (! Schema::hasTable('app_notifications')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (! Schema::hasColumn('app_notifications', 'is_system')) {
|
||||
Schema::table('app_notifications', function (Blueprint $table) {
|
||||
$table->boolean('is_system')->default(false)->after('created_by')->index();
|
||||
});
|
||||
}
|
||||
|
||||
// بکفیل: سیستمی = بدون created_by یا لیبل قدیمی «سیستمی»
|
||||
DB::table('app_notifications')
|
||||
->where(function ($q) {
|
||||
$q->whereNull('created_by')
|
||||
->orWhere('audience_label', 'like', 'سیستمی%');
|
||||
})
|
||||
->update(['is_system' => true]);
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
if (Schema::hasTable('app_notifications') && Schema::hasColumn('app_notifications', 'is_system')) {
|
||||
Schema::table('app_notifications', function (Blueprint $table) {
|
||||
$table->dropColumn('is_system');
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user