feat: adds pgsql compatibility (#72)

This commit is contained in:
hackerESQ
2025-03-10 21:17:24 -05:00
committed by GitHub
parent 9e48f21c8d
commit 7ab6f79e56
15 changed files with 195 additions and 139 deletions
@@ -17,7 +17,7 @@ return new class extends Migration
{
Schema::create('portfolios', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->string('title');
$table->string('title')->when(config('database.default') != 'sqlite', fn ($ctx) => $ctx->fulltext());
$table->text('notes')->nullable();
$table->boolean('wishlist')->default(false);
$table->timestamps();
@@ -18,8 +18,8 @@ class CreateMarketDataTable extends Migration
public function up()
{
Schema::create('market_data', function (Blueprint $table) {
$table->string('symbol', 15)->primary();
$table->string('name')->nullable();
$table->string('symbol', 25)->primary();
$table->string('name')->nullable()->when(config('database.default') != 'sqlite', fn ($ctx) => $ctx->fulltext());
$table->float('market_value', 12, 4)->nullable();
$table->float('fifty_two_week_low', 12, 4)->nullable();
$table->float('fifty_two_week_high', 12, 4)->nullable();
@@ -18,11 +18,9 @@ class CreateDividendsTable extends Migration
Schema::create('dividends', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->date('date');
$table->string('symbol', 15);
$table->string('symbol', 25);
$table->float('dividend_amount', 12, 4);
$table->timestamps();
$table->foreign('symbol')->references('symbol')->on('market_data');
});
}
@@ -18,11 +18,9 @@ class CreateSplitsTable extends Migration
Schema::create('splits', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->date('date');
$table->string('symbol', 15);
$table->string('symbol', 25);
$table->float('split_amount', 12, 4);
$table->timestamps();
$table->foreign('symbol')->references('symbol')->on('market_data');
});
}
@@ -18,7 +18,7 @@ class CreateTransactionsTable extends Migration
{
Schema::create('transactions', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->string('symbol', 15);
$table->string('symbol', 25);
$table->foreignIdFor(Portfolio::class, 'portfolio_id')->constrained()->onDelete('cascade');
$table->string('transaction_type', 15);
$table->float('quantity', 12, 4);
@@ -27,8 +27,6 @@ class CreateTransactionsTable extends Migration
$table->boolean('split')->default(false);
$table->date('date');
$table->timestamps();
$table->foreign('symbol')->references('symbol')->on('market_data');
});
}
@@ -19,7 +19,7 @@ class CreateHoldingsTable extends Migration
Schema::create('holdings', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->foreignIdFor(Portfolio::class, 'portfolio_id')->constrained()->onDelete('cascade');
$table->string('symbol', 15);
$table->string('symbol', 25)->when(config('database.default') != 'sqlite', fn ($ctx) => $ctx->fulltext());
$table->float('quantity', 12, 4);
$table->float('average_cost_basis', 12, 4)->default(0);
$table->float('total_cost_basis', 12, 4)->default(0);
@@ -27,8 +27,6 @@ class CreateHoldingsTable extends Migration
$table->float('dividends_earned', 12, 4)->default(0);
$table->timestamp('splits_synced_at')->nullable();
$table->timestamps();
$table->foreign('symbol')->references('symbol')->on('market_data');
});
}