diff --git a/app/Models/Portfolio.php b/app/Models/Portfolio.php index 8a533b3..0b07db7 100644 --- a/app/Models/Portfolio.php +++ b/app/Models/Portfolio.php @@ -3,11 +3,13 @@ namespace App\Models; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Concerns\HasUuids; use Illuminate\Database\Eloquent\Factories\HasFactory; class Portfolio extends Model { use HasFactory; + use HasUuids; /** * The attributes that are mass assignable. diff --git a/app/Models/User.php b/app/Models/User.php index 6c2e25a..09e2523 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -3,12 +3,13 @@ namespace App\Models; // use Illuminate\Contracts\Auth\MustVerifyEmail; -use Illuminate\Database\Eloquent\Factories\HasFactory; -use Illuminate\Foundation\Auth\User as Authenticatable; +use Laravel\Sanctum\HasApiTokens; +use Laravel\Jetstream\HasProfilePhoto; use Illuminate\Notifications\Notifiable; use Laravel\Fortify\TwoFactorAuthenticatable; -use Laravel\Jetstream\HasProfilePhoto; -use Laravel\Sanctum\HasApiTokens; +use Illuminate\Database\Eloquent\Concerns\HasUuids; +use Illuminate\Database\Eloquent\Factories\HasFactory; +use Illuminate\Foundation\Auth\User as Authenticatable; class User extends Authenticatable { @@ -17,6 +18,7 @@ class User extends Authenticatable use HasProfilePhoto; use Notifiable; use TwoFactorAuthenticatable; + use HasUuids; /** * The attributes that are mass assignable. diff --git a/database/migrations/0001_01_01_000000_create_users_table.php b/database/migrations/0001_01_01_000000_create_users_table.php index 31d7807..f60b77d 100644 --- a/database/migrations/0001_01_01_000000_create_users_table.php +++ b/database/migrations/0001_01_01_000000_create_users_table.php @@ -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(); - }); } /** diff --git a/database/migrations/0001_01_01_000001_create_cache_table.php b/database/migrations/0001_01_01_000001_create_cache_table.php deleted file mode 100644 index b9c106b..0000000 --- a/database/migrations/0001_01_01_000001_create_cache_table.php +++ /dev/null @@ -1,35 +0,0 @@ -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'); - } -}; diff --git a/database/migrations/0001_01_01_000002_create_failed_jobs_table.php b/database/migrations/0001_01_01_000002_create_failed_jobs_table.php new file mode 100644 index 0000000..249da81 --- /dev/null +++ b/database/migrations/0001_01_01_000002_create_failed_jobs_table.php @@ -0,0 +1,32 @@ +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'); + } +}; diff --git a/database/migrations/0001_01_01_000002_create_jobs_table.php b/database/migrations/0001_01_01_000002_create_jobs_table.php deleted file mode 100644 index 425e705..0000000 --- a/database/migrations/0001_01_01_000002_create_jobs_table.php +++ /dev/null @@ -1,57 +0,0 @@ -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'); - } -}; diff --git a/database/migrations/2021_01_30_102537_create_portfolios_table.php b/database/migrations/2021_01_30_102537_create_portfolios_table.php index 0aea361..3ee0a89 100644 --- a/database/migrations/2021_01_30_102537_create_portfolios_table.php +++ b/database/migrations/2021_01_30_102537_create_portfolios_table.php @@ -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); diff --git a/database/migrations/2021_01_30_112537_create_portfolio_users_table.php b/database/migrations/2021_01_30_112537_create_portfolio_users_table.php index 065442a..0a9b615 100644 --- a/database/migrations/2021_01_30_112537_create_portfolio_users_table.php +++ b/database/migrations/2021_01_30_112537_create_portfolio_users_table.php @@ -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']); }); diff --git a/database/migrations/2021_02_25_041227_create_daily_change_table.php b/database/migrations/2021_02_25_041227_create_daily_change_table.php index 653618d..6e72094 100644 --- a/database/migrations/2021_02_25_041227_create_daily_change_table.php +++ b/database/migrations/2021_02_25_041227_create_daily_change_table.php @@ -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']); }); diff --git a/database/migrations/2021_02_25_041236_create_dividends_table.php b/database/migrations/2021_02_25_041236_create_dividends_table.php index 21528be..ff516a9 100644 --- a/database/migrations/2021_02_25_041236_create_dividends_table.php +++ b/database/migrations/2021_02_25_041236_create_dividends_table.php @@ -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(); }); diff --git a/database/migrations/2021_02_25_041246_create_splits_table.php b/database/migrations/2021_02_25_041246_create_splits_table.php index 21093df..a3727cf 100644 --- a/database/migrations/2021_02_25_041246_create_splits_table.php +++ b/database/migrations/2021_02_25_041246_create_splits_table.php @@ -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(); }); diff --git a/database/migrations/2021_02_25_041257_create_transactions_table.php b/database/migrations/2021_02_25_041257_create_transactions_table.php index abd03f3..a567825 100644 --- a/database/migrations/2021_02_25_041257_create_transactions_table.php +++ b/database/migrations/2021_02_25_041257_create_transactions_table.php @@ -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(); diff --git a/database/migrations/2021_02_26_041257_create_market_data_table.php b/database/migrations/2021_02_26_041257_create_market_data_table.php index 2b01286..f8345df 100644 --- a/database/migrations/2021_02_26_041257_create_market_data_table.php +++ b/database/migrations/2021_02_26_041257_create_market_data_table.php @@ -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); diff --git a/database/migrations/2021_09_06_014744_create_holdings_table.php b/database/migrations/2021_09_06_014744_create_holdings_table.php index 568bf98..a5f4b09 100644 --- a/database/migrations/2021_09_06_014744_create_holdings_table.php +++ b/database/migrations/2021_09_06_014744_create_holdings_table.php @@ -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(); diff --git a/database/migrations/2024_07_30_012537_create_personal_access_tokens_table.php b/database/migrations/2024_07_30_012537_create_personal_access_tokens_table.php index e828ad8..29db28a 100644 --- a/database/migrations/2024_07_30_012537_create_personal_access_tokens_table.php +++ b/database/migrations/2024_07_30_012537_create_personal_access_tokens_table.php @@ -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();