fix notif 3
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* مخاطبگذاری اعلان: همه / گروه / تکی + جدول گیرندگان (اسنپشات زمان ارسال).
|
||||
*/
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
if (Schema::hasTable('app_notifications')) {
|
||||
Schema::table('app_notifications', function (Blueprint $table) {
|
||||
if (! Schema::hasColumn('app_notifications', 'audience_type')) {
|
||||
$table->string('audience_type', 32)->default('all')->after('is_active');
|
||||
}
|
||||
if (! Schema::hasColumn('app_notifications', 'segment_keys')) {
|
||||
$table->json('segment_keys')->nullable()->after('audience_type');
|
||||
}
|
||||
if (! Schema::hasColumn('app_notifications', 'audience_label')) {
|
||||
$table->string('audience_label', 255)->nullable()->after('segment_keys');
|
||||
}
|
||||
if (! Schema::hasColumn('app_notifications', 'recipients_count')) {
|
||||
$table->unsignedInteger('recipients_count')->default(0)->after('audience_label');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (! Schema::hasTable('app_notification_recipients')) {
|
||||
Schema::create('app_notification_recipients', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('notification_id')->index();
|
||||
$table->unsignedBigInteger('customer_id')->index();
|
||||
$table->timestamps();
|
||||
$table->unique(['notification_id', 'customer_id'], 'app_notif_recipients_unique');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('app_notification_recipients');
|
||||
|
||||
if (Schema::hasTable('app_notifications')) {
|
||||
Schema::table('app_notifications', function (Blueprint $table) {
|
||||
foreach (['recipients_count', 'audience_label', 'segment_keys', 'audience_type'] as $col) {
|
||||
if (Schema::hasColumn('app_notifications', $col)) {
|
||||
$table->dropColumn($col);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user