2024-08-03 14:21:29 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
use App\Models\Portfolio;
|
2024-08-10 13:30:34 -05:00
|
|
|
use App\Models\MarketData;
|
2024-08-03 14:21:29 -05:00
|
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
|
|
|
use Illuminate\Database\Migrations\Migration;
|
|
|
|
|
|
|
|
|
|
class CreateTransactionsTable extends Migration
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Run the migrations.
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
public function up()
|
|
|
|
|
{
|
|
|
|
|
Schema::create('transactions', function (Blueprint $table) {
|
2024-08-07 12:45:01 -05:00
|
|
|
$table->uuid('id')->primary();
|
2024-08-10 13:30:34 -05:00
|
|
|
$table->foreignIdFor(MarketData::class, 'symbol');
|
|
|
|
|
$table->foreignIdFor(Portfolio::class, 'portfolio_id')->constrained()->onDelete('cascade');
|
2024-08-07 12:45:01 -05:00
|
|
|
$table->string('transaction_type', 15);
|
2024-08-03 14:21:29 -05:00
|
|
|
$table->float('quantity', 12, 4);
|
|
|
|
|
$table->float('cost_basis', 12, 4);
|
|
|
|
|
$table->float('sale_price', 12, 4)->nullable();
|
|
|
|
|
$table->boolean('split')->nullable();
|
|
|
|
|
$table->date('date');
|
|
|
|
|
$table->timestamps();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Reverse the migrations.
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
public function down()
|
|
|
|
|
{
|
|
|
|
|
Schema::dropIfExists('transactions');
|
|
|
|
|
}
|
|
|
|
|
}
|