31 lines
912 B
PHP
31 lines
912 B
PHP
<?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
|
|
{
|
|
Schema::create('transactions', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
|
$table->string('code')->unique();
|
|
$table->text('address');
|
|
$table->string('phone');
|
|
$table->enum('status', ['pending', 'paid', 'processing', 'shipped', 'completed', 'cancelled'])->default('pending');
|
|
$table->decimal('total', 12, 2);
|
|
$table->timestamps();
|
|
|
|
$table->index(['user_id', 'created_at']);
|
|
$table->index('status');
|
|
});
|
|
}
|
|
|
|
public function down(): void
|
|
{
|
|
Schema::dropIfExists('transactions');
|
|
}
|
|
};
|