39 lines
1.3 KiB
PHP
39 lines
1.3 KiB
PHP
<?php
|
|
|
|
use App\Enums\RedemptionStatus;
|
|
use Illuminate\Database\Migrations\Migration;
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
|
return new class extends Migration
|
|
{
|
|
/**
|
|
* Run the migrations.
|
|
*/
|
|
public function up(): void
|
|
{
|
|
Schema::create('redemptions', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
|
$table->foreignId('reward_id')->constrained()->cascadeOnDelete();
|
|
$table->string('code')->unique();
|
|
$table->unsignedInteger('points_spent');
|
|
$table->enum('status', RedemptionStatus::values())->default(RedemptionStatus::WAITING_PICKUP)->comment(RedemptionStatus::comment());
|
|
$table->timestamp('expires_at');
|
|
$table->timestamp('verified_at')->nullable();
|
|
$table->foreignId('verified_by')->nullable()->constrained('users')->nullOnDelete();
|
|
$table->timestamp('created_at')->useCurrent();
|
|
$table->timestamp('updated_at')->nullable()->useCurrentOnUpdate();
|
|
$table->softDeletes();
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Reverse the migrations.
|
|
*/
|
|
public function down(): void
|
|
{
|
|
Schema::dropIfExists('redemptions');
|
|
}
|
|
};
|