| 123456789101112131415161718192021222324 |
- 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;
|