31 lines
810 B
PHP
31 lines
810 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
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('entries', function (Blueprint $table): void {
|
||
|
|
$table->id();
|
||
|
|
$table->foreignId('tracker_id')->constrained()->cascadeOnDelete();
|
||
|
|
$table->date('date');
|
||
|
|
$table->decimal('quantity', 12, 6);
|
||
|
|
$table->decimal('unit_price', 12, 4)->nullable();
|
||
|
|
$table->decimal('total_cost', 12, 2)->nullable();
|
||
|
|
$table->timestamps();
|
||
|
|
|
||
|
|
$table->index(['tracker_id', 'date']);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
public function down(): void
|
||
|
|
{
|
||
|
|
Schema::dropIfExists('entries');
|
||
|
|
}
|
||
|
|
};
|