move to uuids for portfolios, users, and all market data

This commit is contained in:
hackerESQ
2024-08-07 12:43:49 -05:00
parent 45b3800389
commit 4a2da61fa6
13 changed files with 47 additions and 116 deletions
@@ -12,13 +12,12 @@ return new class extends Migration
public function up(): void
{
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->uuid('id')->primary();
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->foreignId('current_team_id')->nullable();
$table->string('profile_photo_path', 2048)->nullable();
$table->timestamps();
});
@@ -28,15 +27,6 @@ return new class extends Migration
$table->string('token');
$table->timestamp('created_at')->nullable();
});
Schema::create('sessions', function (Blueprint $table) {
$table->string('id')->primary();
$table->foreignId('user_id')->nullable()->index();
$table->string('ip_address', 45)->nullable();
$table->text('user_agent')->nullable();
$table->longText('payload');
$table->integer('last_activity')->index();
});
}
/**
@@ -1,35 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('cache', function (Blueprint $table) {
$table->string('key')->primary();
$table->mediumText('value');
$table->integer('expiration');
});
Schema::create('cache_locks', function (Blueprint $table) {
$table->string('key')->primary();
$table->string('owner');
$table->integer('expiration');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('cache');
Schema::dropIfExists('cache_locks');
}
};
@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('failed_jobs', function (Blueprint $table) {
$table->id();
$table->string('uuid')->unique();
$table->text('connection');
$table->text('queue');
$table->longText('payload');
$table->longText('exception');
$table->timestamp('failed_at')->useCurrent();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('failed_jobs');
}
};
@@ -1,57 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('jobs', function (Blueprint $table) {
$table->id();
$table->string('queue')->index();
$table->longText('payload');
$table->unsignedTinyInteger('attempts');
$table->unsignedInteger('reserved_at')->nullable();
$table->unsignedInteger('available_at');
$table->unsignedInteger('created_at');
});
Schema::create('job_batches', function (Blueprint $table) {
$table->string('id')->primary();
$table->string('name');
$table->integer('total_jobs');
$table->integer('pending_jobs');
$table->integer('failed_jobs');
$table->longText('failed_job_ids');
$table->mediumText('options')->nullable();
$table->integer('cancelled_at')->nullable();
$table->integer('created_at');
$table->integer('finished_at')->nullable();
});
Schema::create('failed_jobs', function (Blueprint $table) {
$table->id();
$table->string('uuid')->unique();
$table->text('connection');
$table->text('queue');
$table->longText('payload');
$table->longText('exception');
$table->timestamp('failed_at')->useCurrent();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('jobs');
Schema::dropIfExists('job_batches');
Schema::dropIfExists('failed_jobs');
}
};
@@ -14,7 +14,7 @@ return new class extends Migration
public function up()
{
Schema::create('portfolios', function (Blueprint $table) {
$table->id();
$table->uuid('id')->primary();
$table->string('title');
$table->text('notes')->nullable();
$table->boolean('wishlist')->default(false);
@@ -19,6 +19,7 @@ return new class extends Migration
$table->foreignIdFor(Portfolio::class, 'portfolio_id')->onDelete('cascade');
$table->foreignIdFor(User::class, 'user_id')->onDelete('cascade');
$table->boolean('owner')->default(false);
$table->boolean('read')->default(false);
$table->boolean('write')->default(false);
$table->primary(['portfolio_id', 'user_id']);
});
@@ -22,7 +22,7 @@ class CreateDailyChangeTable extends Migration
$table->float('total_gain_loss', 12, 4)->nullable();
$table->float('total_dividends', 12, 4)->nullable();
$table->float('realized_gains', 12, 4)->nullable();
$table->text('notes')->nullable();
$table->text('annotation')->nullable();
$table->primary(['date', 'portfolio_id']);
});
@@ -14,9 +14,9 @@ class CreateDividendsTable extends Migration
public function up()
{
Schema::create('dividends', function (Blueprint $table) {
$table->id();
$table->uuid('id')->primary();
$table->date('date');
$table->string('symbol');
$table->string('symbol', 15);
$table->float('dividend_amount', 12, 4);
$table->timestamps();
});
@@ -14,9 +14,9 @@ class CreateSplitsTable extends Migration
public function up()
{
Schema::create('splits', function (Blueprint $table) {
$table->id();
$table->uuid('id')->primary();
$table->date('date');
$table->string('symbol');
$table->string('symbol', 15);
$table->float('split_amount', 12, 4);
$table->timestamps();
});
@@ -15,10 +15,10 @@ class CreateTransactionsTable extends Migration
public function up()
{
Schema::create('transactions', function (Blueprint $table) {
$table->id();
$table->string('symbol');
$table->uuid('id')->primary();
$table->string('symbol', 15);
$table->foreignIdFor(Portfolio::class, 'portfolio_id')->onDelete('cascade');
$table->string('transaction_type');
$table->string('transaction_type', 15);
$table->float('quantity', 12, 4);
$table->float('cost_basis', 12, 4);
$table->float('sale_price', 12, 4)->nullable();
@@ -14,7 +14,7 @@ class CreateMarketDataTable extends Migration
public function up()
{
Schema::create('market_data', function (Blueprint $table) {
$table->string('symbol')->primary();
$table->string('symbol', 15)->primary();
$table->string('name');
$table->float('market_value', 12, 4);
$table->float('fifty_two_week_low', 12, 4);
@@ -15,9 +15,9 @@ class CreateHoldingsTable extends Migration
public function up()
{
Schema::create('holdings', function (Blueprint $table) {
$table->id();
$table->uuid('id')->primary();
$table->foreignIdFor(Portfolio::class, 'portfolio_id')->onDelete('cascade');
$table->string('symbol');
$table->string('symbol', 15);
$table->float('quantity', 12, 4);
$table->float('average_cost_basis', 12, 4);
$table->float('total_cost_basis', 12, 4)->nullable();
@@ -13,7 +13,7 @@ return new class extends Migration
{
Schema::create('personal_access_tokens', function (Blueprint $table) {
$table->id();
$table->morphs('tokenable');
$table->uuidMorphs('tokenable');
$table->string('name');
$table->string('token', 64)->unique();
$table->text('abilities')->nullable();