mirror of
https://github.com/henry4682/finance_app.git
synced 2026-07-16 00:10:00 +00:00
40 lines
1.2 KiB
PHP
40 lines
1.2 KiB
PHP
<?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('securities', function (Blueprint $table) {
|
|
$table->id();
|
|
|
|
$table->string('code', 20);
|
|
$table->enum('type', ['stock', 'etf', 'fund']);
|
|
$table->string('source', 20); // twse, tpex, cnyes
|
|
$table->string('name'); // 中文名稱/簡稱
|
|
|
|
$table->decimal('latest_price', 15, 4)->nullable(); // 最新報價/淨值
|
|
$table->timestamp('latest_price_at')->nullable(); // 最新報價/淨值時間
|
|
$table->decimal('change_amount', 15, 4)->nullable(); // 漲跌
|
|
$table->decimal('change_rate', 8, 4)->nullable(); // 漲跌幅(%)
|
|
|
|
$table->jsonb('meta')->nullable(); // 基金專屬額外資訊(category、riskLevel、isinCode...)
|
|
|
|
$table->timestamps();
|
|
|
|
$table->unique(['code', 'type']);
|
|
});
|
|
}
|
|
|
|
public function down(): void
|
|
{
|
|
Schema::dropIfExists('securities');
|
|
}
|
|
};
|