2024-08-03 14:21:29 -05:00
|
|
|
<?php
|
|
|
|
|
|
2025-01-28 17:33:54 -06:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2025-01-28 17:14:49 -06:00
|
|
|
use App\Models\Portfolio;
|
2024-08-03 14:21:29 -05:00
|
|
|
use Illuminate\Database\Migrations\Migration;
|
2025-01-28 17:14:49 -06:00
|
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
|
|
|
use Illuminate\Support\Facades\Schema;
|
2024-08-03 14:21:29 -05:00
|
|
|
|
|
|
|
|
class CreateHoldingsTable extends Migration
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Run the migrations.
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
public function up()
|
|
|
|
|
{
|
|
|
|
|
Schema::create('holdings', function (Blueprint $table) {
|
2025-01-28 17:14:49 -06:00
|
|
|
$table->uuid('id')->primary();
|
2024-08-10 13:30:34 -05:00
|
|
|
$table->foreignIdFor(Portfolio::class, 'portfolio_id')->constrained()->onDelete('cascade');
|
2025-03-10 21:17:24 -05:00
|
|
|
$table->string('symbol', 25)->when(config('database.default') != 'sqlite', fn ($ctx) => $ctx->fulltext());
|
2024-08-03 14:21:29 -05:00
|
|
|
$table->float('quantity', 12, 4);
|
2025-01-24 19:17:55 -06:00
|
|
|
$table->float('average_cost_basis', 12, 4)->default(0);
|
|
|
|
|
$table->float('total_cost_basis', 12, 4)->default(0);
|
|
|
|
|
$table->float('realized_gain_dollars', 12, 4)->default(0);
|
|
|
|
|
$table->float('dividends_earned', 12, 4)->default(0);
|
2024-08-10 13:30:34 -05:00
|
|
|
$table->timestamp('splits_synced_at')->nullable();
|
2024-08-03 14:21:29 -05:00
|
|
|
$table->timestamps();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Reverse the migrations.
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
public function down()
|
|
|
|
|
{
|
|
|
|
|
Schema::dropIfExists('holdings');
|
|
|
|
|
}
|
|
|
|
|
}
|