| 12345678910111213141516171819202122232425 |
- <?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
- {
- foreach (['activity_rewards', 'activity_user', 'promotion_activities'] as $name) {
- if (!Schema::hasTable($name)) continue;
- Schema::table($name, function (Blueprint $table) use ($name) {
- foreach (['start_time', 'end_time'] as $field) {
- if ($name === 'promotion_activities') $table->unsignedBigInteger($field)->nullable()->change();
- else $table->integer($field)->nullable()->change();
- }
- });
- }
- }
- public function down(): void
- {
- // 保留永久活动的空时间,回滚时不编造日期或删除活动数据。
- }
- };
|