chore: clean up market data seed

This commit is contained in:
hackerESQ
2025-03-07 19:15:10 -06:00
parent 00fbdec6f1
commit 10e6de8df4
2 changed files with 4 additions and 4 deletions
@@ -2,7 +2,6 @@
declare(strict_types=1); declare(strict_types=1);
use App\Models\MarketData;
use App\Models\Portfolio; use App\Models\Portfolio;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
@@ -20,7 +19,7 @@ class CreateHoldingsTable extends Migration
Schema::create('holdings', function (Blueprint $table) { Schema::create('holdings', function (Blueprint $table) {
$table->uuid('id')->primary(); $table->uuid('id')->primary();
$table->foreignIdFor(Portfolio::class, 'portfolio_id')->constrained()->onDelete('cascade'); $table->foreignIdFor(Portfolio::class, 'portfolio_id')->constrained()->onDelete('cascade');
$table->foreignIdFor(MarketData::class, 'symbol'); $table->string('symbol', 15);
$table->float('quantity', 12, 4); $table->float('quantity', 12, 4);
$table->float('average_cost_basis', 12, 4)->default(0); $table->float('average_cost_basis', 12, 4)->default(0);
$table->float('total_cost_basis', 12, 4)->default(0); $table->float('total_cost_basis', 12, 4)->default(0);
@@ -28,6 +27,8 @@ class CreateHoldingsTable extends Migration
$table->float('dividends_earned', 12, 4)->default(0); $table->float('dividends_earned', 12, 4)->default(0);
$table->timestamp('splits_synced_at')->nullable(); $table->timestamp('splits_synced_at')->nullable();
$table->timestamps(); $table->timestamps();
$table->foreign('symbol')->references('symbol')->on('market_data');
}); });
} }
+1 -2
View File
@@ -63,9 +63,8 @@ class MarketDataSeeder extends Seeder
// final clean up // final clean up
if (! empty($this->rows)) { if (! empty($this->rows)) {
echo 'did '.$rowCount.' already. doing '.count($this->rows).' more';
$this->bulkInsert($this->rows);
$this->bulkInsert($this->rows);
} }
// Close the CSV file // Close the CSV file