33 lines
826 B
PHP
33 lines
826 B
PHP
<?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('purchases', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->date('date');
|
|
$table->decimal('shares', 12, 6); // Supports fractional shares
|
|
$table->decimal('price_per_share', 8, 4); // Price in euros
|
|
$table->decimal('total_cost', 12, 2); // Total cost in euros
|
|
$table->timestamps();
|
|
|
|
$table->index('date');
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Reverse the migrations.
|
|
*/
|
|
public function down(): void
|
|
{
|
|
Schema::dropIfExists('purchases');
|
|
}
|
|
};
|