Просмотр исходного кода

添加股票历史数据表迁移

yourname 7 месяцев назад
Родитель
Сommit
063c20f5d7
2 измененных файлов с 22 добавлено и 0 удалено
  1. 21 0
      server/migrations/011_createStockDataTable.ts
  2. 1 0
      版本迭代需求.md

+ 21 - 0
server/migrations/011_createStockDataTable.ts

@@ -0,0 +1,21 @@
+import type { MigrationLiveDefinition } from '@d8d-appcontainer/types'
+
+const createStockDataTable: MigrationLiveDefinition = {
+  name: "create_stock_data_table",
+  up: async (api) => {
+    await api.schema.createTable('stock_data', (table) => {
+      table.increments("id").primary();
+      table.string("code").notNullable().comment("股票代码");
+      table.jsonb("data").notNullable().comment("股票数据");
+      table.timestamps(true, true);
+  
+      // 添加索引
+      table.unique("code");
+    });
+  },
+  down: async (api) => {
+    await api.schema.dropTable('stock_data');
+  }
+}
+
+export default createStockDataTable;

+ 1 - 0
版本迭代需求.md

@@ -1,4 +1,5 @@
 2025.05.15 0.1.1
 2025.05.15 0.1.1
+添加股票历史数据表迁移
 添加股票训练入口
 添加股票训练入口
 迁移入股票训练模块
 迁移入股票训练模块