gamtest / database /migrations /2025_07_26_194206_create_revenue_tracking_table.php
veela4's picture
Upload folder using huggingface_hub
70ba896 verified
<?php
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('revenue_tracking', function (Blueprint $table) {
$table->id();
$table->foreignId('order_id')->constrained()->onDelete('cascade');
$table->decimal('amount', 10, 2);
$table->decimal('cost', 10, 2)->default(0); // Product cost for profit calculation
$table->decimal('profit_margin', 5, 4)->default(0); // Calculated profit margin
$table->string('product_name')->nullable();
$table->integer('quantity')->default(1);
$table->timestamps();
// Indexes for performance
$table->index('order_id');
$table->index('created_at');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('revenue_tracking');
}
};