2026_10_13_120000_add_activity_eligibility_fields.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. use Illuminate\Database\Migrations\Migration;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Support\Facades\Schema;
  5. return new class extends Migration {
  6. public function up()
  7. {
  8. Schema::table('activity_rewards', function (Blueprint $table) {
  9. $table->json('publish_platforms')->nullable()->comment('发布平台PC/H5/APP,空表示全部');
  10. $table->decimal('budget', 14, 2)->nullable()->comment('奖励总预算,NULL不限,0停止发奖');
  11. $table->decimal('budget_used', 14, 2)->default(0)->comment('上线后已发奖励总额');
  12. $table->unsignedInteger('sort')->default(0);
  13. $table->boolean('register_time_limited')->default(false);
  14. $table->dateTime('register_start_time')->nullable();
  15. $table->dateTime('register_end_time')->nullable();
  16. $table->json('register_platforms')->nullable()->comment('会员首次成功登录平台,空表示全部');
  17. $table->boolean('deposit_limited')->default(false);
  18. $table->decimal('deposit_min', 14, 2)->nullable();
  19. $table->decimal('deposit_max', 14, 2)->nullable();
  20. $table->boolean('show_ineligible')->default(true)->comment('不符合会员资格时是否展示');
  21. });
  22. if (Schema::hasTable('yuebao_item') && !Schema::hasColumn('yuebao_item', 'activity_id')) {
  23. Schema::table('yuebao_item', function (Blueprint $table) {
  24. $table->unsignedBigInteger('activity_id')->nullable()->index()->comment('新持仓关联活动预算');
  25. });
  26. }
  27. }
  28. public function down()
  29. {
  30. if (Schema::hasTable('yuebao_item') && Schema::hasColumn('yuebao_item', 'activity_id')) {
  31. Schema::table('yuebao_item', function (Blueprint $table) {
  32. $table->dropIndex(['activity_id']);
  33. $table->dropColumn('activity_id');
  34. });
  35. }
  36. Schema::table('activity_rewards', function (Blueprint $table) {
  37. $table->dropColumn(['publish_platforms', 'budget', 'budget_used', 'sort',
  38. 'register_time_limited', 'register_start_time', 'register_end_time',
  39. 'register_platforms', 'deposit_limited', 'deposit_min', 'deposit_max', 'show_ineligible']);
  40. });
  41. }
  42. };