013_createClassroomDataTable.ts 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import type { MigrationLiveDefinition } from '@d8d-appcontainer/types'
  2. const createClassroomDataTable: MigrationLiveDefinition = {
  3. name: "create_classroom_data",
  4. up: async (api) => {
  5. // 教室数据表
  6. await api.schema.createTable('classroom_data', table => {
  7. table.increments('id').primary().comment('数据ID');
  8. table.string('classroom_no').nullable().comment('教室号');
  9. table.timestamp('training_date').nullable().comment('训练日期');
  10. table.string('holding_stock').nullable().comment('持股');
  11. table.string('holding_cash').nullable().comment('持币');
  12. table.string('price').nullable().comment('价格');
  13. table.string('code').nullable().comment('代码');
  14. table.string('status').nullable().comment('状态');
  15. table.string('spare').nullable().comment('备用');
  16. table.string('submit_user').nullable().comment('提交用户');
  17. table.timestamps(true, true);
  18. });
  19. // 交卷记录表
  20. await api.schema.createTable('submission_records', table => {
  21. table.increments('id').primary().comment('数据ID');
  22. table.string('classroom_no').nullable().comment('教室号');
  23. table.string('user_id').nullable().comment('用户id');
  24. table.string('nickname').nullable().comment('昵称');
  25. table.decimal('score', 10, 2).nullable().comment('成绩');
  26. table.string('code').nullable().comment('代码');
  27. table.timestamp('training_date').nullable().comment('训练日期');
  28. table.string('mark').nullable().comment('标记');
  29. table.integer('status').nullable().comment('状态');
  30. table.string('holding_stock').nullable().comment('持股');
  31. table.string('holding_cash').nullable().comment('持币');
  32. table.decimal('price', 10, 2).nullable().comment('价格');
  33. table.decimal('profit_amount', 10, 2).nullable().comment('收益金额');
  34. table.decimal('profit_percent', 10, 2).nullable().comment('收益率');
  35. table.decimal('total_profit_amount', 10, 2).nullable().comment('累计收益金额');
  36. table.decimal('total_profit_percent', 10, 2).nullable().comment('累计收益率');
  37. table.timestamps(true, true);
  38. });
  39. },
  40. down: async (api) => {
  41. await api.schema.dropTable('submission_records');
  42. await api.schema.dropTable('classroom_data');
  43. }
  44. }
  45. export default createClassroomDataTable;