update migrations

This commit is contained in:
hackerESQ
2024-08-10 13:30:34 -05:00
parent 804b4698f0
commit 7707c6dcb3
7 changed files with 19 additions and 13 deletions
@@ -16,8 +16,8 @@ return new class extends Migration
public function up()
{
Schema::create('portfolio_user', function (Blueprint $table) {
$table->foreignIdFor(Portfolio::class, 'portfolio_id')->onDelete('cascade');
$table->foreignIdFor(User::class, 'user_id')->onDelete('cascade');
$table->foreignIdFor(Portfolio::class, 'portfolio_id')->constrained()->onDelete('cascade');
$table->foreignIdFor(User::class, 'user_id')->constrained()->onDelete('cascade');
$table->boolean('owner')->default(false);
$table->boolean('write')->default(false);
$table->primary(['portfolio_id', 'user_id']);
@@ -19,8 +19,8 @@ class CreateMarketDataTable extends Migration
$table->float('market_value', 12, 4);
$table->float('fifty_two_week_low', 12, 4);
$table->float('fifty_two_week_high', 12, 4);
$table->timestamp('splits_synced_to_holdings_at')->nullable();
$table->timestamp('dividend_date')->nullable();
$table->timestamp('last_dividend_date')->nullable();
$table->float('last_dividend_amount', 12, 4);
$table->timestamps();
});
}
@@ -16,7 +16,7 @@ class CreateDailyChangeTable extends Migration
{
Schema::create('daily_change', function (Blueprint $table) {
$table->date('date');
$table->foreignIdFor(Portfolio::class, 'portfolio_id')->onDelete('cascade');
$table->foreignIdFor(Portfolio::class, 'portfolio_id')->constrained()->onDelete('cascade');
$table->float('total_market_value', 12, 4)->nullable();
$table->float('total_cost_basis', 12, 4)->nullable();
$table->float('total_gain_loss', 12, 4)->nullable();
@@ -1,5 +1,6 @@
<?php
use App\Models\MarketData;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
@@ -16,7 +17,7 @@ class CreateDividendsTable extends Migration
Schema::create('dividends', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->date('date');
$table->string('symbol', 15);
$table->foreignIdFor(MarketData::class, 'symbol');
$table->float('dividend_amount', 12, 4);
$table->timestamps();
});
@@ -1,8 +1,9 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use App\Models\MarketData;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateSplitsTable extends Migration
{
@@ -16,7 +17,7 @@ class CreateSplitsTable extends Migration
Schema::create('splits', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->date('date');
$table->string('symbol', 15);
$table->foreignIdFor(MarketData::class, 'symbol');
$table->float('split_amount', 12, 4);
$table->timestamps();
});
@@ -1,6 +1,7 @@
<?php
use App\Models\Portfolio;
use App\Models\MarketData;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
@@ -16,8 +17,8 @@ class CreateTransactionsTable extends Migration
{
Schema::create('transactions', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->string('symbol', 15);
$table->foreignIdFor(Portfolio::class, 'portfolio_id')->onDelete('cascade');
$table->foreignIdFor(MarketData::class, 'symbol');
$table->foreignIdFor(Portfolio::class, 'portfolio_id')->constrained()->onDelete('cascade');
$table->string('transaction_type', 15);
$table->float('quantity', 12, 4);
$table->float('cost_basis', 12, 4);
@@ -1,6 +1,7 @@
<?php
use App\Models\Portfolio;
use App\Models\MarketData;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
@@ -16,13 +17,15 @@ class CreateHoldingsTable extends Migration
{
Schema::create('holdings', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->foreignIdFor(Portfolio::class, 'portfolio_id')->onDelete('cascade');
$table->string('symbol', 15);
$table->foreignIdFor(Portfolio::class, 'portfolio_id')->constrained()->onDelete('cascade');
$table->foreignIdFor(MarketData::class, 'symbol');
$table->float('quantity', 12, 4);
$table->float('average_cost_basis', 12, 4);
$table->float('total_cost_basis', 12, 4)->nullable();
$table->float('realized_gain_loss_dollars', 12, 4)->nullable();
$table->float('dividends_earned', 12, 4)->nullable();
$table->timestamp('splits_synced_at')->nullable();
$table->timestamp('dividends_synced_at')->nullable();
$table->timestamps();
});
}