| 1234567891011121314151617181920212223242526272829303132333435363738 |
- <?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::hasColumn('promotion_first_deposit_choices', 'activity_id')) {
- Schema::table('promotion_first_deposit_choices', fn (Blueprint $table) => $table->unsignedBigInteger('activity_id')->nullable());
- }
- if (!Schema::hasColumn('promotion_first_deposit_choices', 'rule_snapshot')) {
- Schema::table('promotion_first_deposit_choices', fn (Blueprint $table) => $table->json('rule_snapshot')->nullable());
- }
- if (!Schema::hasTable('promotion_first_deposit_cutovers')) {
- Schema::create('promotion_first_deposit_cutovers', function (Blueprint $table) {
- $table->string('source', 32)->primary();
- $table->unsignedBigInteger('last_order_id');
- });
- }
- // Keep the original automatic reward for orders already placed at cutover.
- $cutovers = array_map(fn (string $source) => [
- 'source' => $source,
- 'last_order_id' => Schema::hasTable($source) ? (int) DB::table($source)->useWritePdo()->max('id') : 0,
- ], ['payment_orders', 'recharges']);
- DB::table('promotion_first_deposit_cutovers')->insertOrIgnore($cutovers);
- }
- public function down(): void
- {
- Schema::dropIfExists('promotion_first_deposit_cutovers');
- Schema::table('promotion_first_deposit_choices', fn (Blueprint $table) => $table->dropColumn(['activity_id', 'rule_snapshot']));
- }
- };
|