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

添加股票日期备注表迁移

yourname 7 месяцев назад
Родитель
Сommit
991b4b38ff
2 измененных файлов с 25 добавлено и 0 удалено
  1. 24 0
      server/migrations/012_createDateNotesTable.ts
  2. 1 0
      版本迭代需求.md

+ 24 - 0
server/migrations/012_createDateNotesTable.ts

@@ -0,0 +1,24 @@
+import type { MigrationLiveDefinition } from '@d8d-appcontainer/types'
+
+const createDateNotesTable: MigrationLiveDefinition = {
+  name: "create_date_notes",
+  up: async (api) => {
+    await api.schema.createTable('date_notes', (table) => {
+      table.increments("id").primary();
+      table.string("code").notNullable().comment("股票代码");
+      table.timestamp("note_date").notNullable().comment("备注日期");
+      table.string("note").notNullable().comment("备注内容");
+      table.timestamps(true, true);
+  
+      // 添加索引
+      table.index("code");
+      table.index("note_date");
+      table.unique(["code", "note_date"]); // 确保同一只股票同一天只有一条备注
+    });
+  },
+  down: async (api) => {
+    await api.schema.dropTable('date_notes');
+  }
+}
+
+export default createDateNotesTable;

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

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