20220912102223_create_train_coures_studytime_table.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. use think\migration\Migrator;
  3. use think\migration\db\Column;
  4. class CreateTrainCouresStudytimeTable extends Migrator
  5. {
  6. /**
  7. * Change Method.
  8. *
  9. * Write your reversible migrations using this method.
  10. *
  11. * More information on writing migrations is available here:
  12. * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
  13. *
  14. * The following commands can be used in this method and Phinx will
  15. * automatically reverse them when rolling back:
  16. *
  17. * createTable
  18. * renameTable
  19. * addColumn
  20. * renameColumn
  21. * addIndex
  22. * addForeignKey
  23. *
  24. * Remember to call "create()" or "update()" and NOT "save()" when working
  25. * with the Table class.
  26. */
  27. public function change()
  28. {
  29. $table = $this->table('train_coures_studytime', ['comment' => '员工学习时长记录表', 'engine'=>'InnoDB']);
  30. $table->addColumn('empid', 'integer',array('comment'=>'员工id','default'=> 0))
  31. ->addColumn('classid', 'integer',array('comment'=>'课程id','default'=> 0))
  32. ->addColumn('course_id', 'integer',array('comment'=>'课件id','default'=> 0))
  33. ->addColumn('study_time', 'integer', array('default'=> 0 ,'comment'=>'学习时长'))
  34. ->addColumn('all_time', 'integer', array('default'=> 0, 'comment'=>'累计时长'))
  35. ->addColumn('addtime', 'timestamp',array('comment'=>'添加时间','default'=> 'CURRENT_TIMESTAMP'))
  36. ->addColumn(Column::tinyInteger('type')->setComment('时长类型')->setDefault(1))
  37. ->create();
  38. $table = $this->table('train_credits', ['comment' => '员工学分表', 'engine'=>'InnoDB']);
  39. $table->addColumn('employee_id', 'integer',array('comment'=>'员工id','default'=> 0))
  40. ->addColumn('root_id', 'integer',array('comment'=>'公司id','default'=> 0))
  41. ->addColumn(Column::tinyInteger('type')->setComment('学分类型1是学习时长累计获得,2是课程完成获得,3是写感悟心得获得')->setDefault(0))
  42. ->addColumn('credits', 'integer', array('default'=> 0 ,'comment'=>'本次增加学分'))
  43. ->addColumn('now_credits', 'integer', array('default'=> 0, 'comment'=>'累计获得学分'))
  44. ->addColumn('addtime', 'timestamp',array('comment'=>'添加时间','default'=> 'CURRENT_TIMESTAMP'))
  45. ->create();
  46. }
  47. }