20220506141132_wrench.php 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. use think\migration\Migrator;
  3. use think\migration\db\Column;
  4. use Phinx\Db\Adapter\MysqlAdapter;
  5. class Wrench extends Migrator
  6. {
  7. /**
  8. * Change Method.
  9. *
  10. * Write your reversible migrations using this method.
  11. *
  12. * More information on writing migrations is available here:
  13. * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
  14. *
  15. * The following commands can be used in this method and Phinx will
  16. * automatically reverse them when rolling back:
  17. *
  18. * createTable
  19. * renameTable
  20. * addColumn
  21. * renameColumn
  22. * addIndex
  23. * addForeignKey
  24. *
  25. * Remember to call "create()" or "update()" and NOT "save()" when working
  26. * with the Table class.
  27. */
  28. public function change()
  29. {
  30. $table = $this->table('wrench', ['engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '液压扳手' ,'id' => 'id','signed' => true ,'primary_key' => ['id']]);
  31. $table->addColumn('number', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => '编号',])
  32. ->addColumn('model', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => '型号',])
  33. ->addColumn('department_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => true,'signed' => true,'comment' => '所属部门',])
  34. ->addColumn('name', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => '名称',])
  35. ->addColumn('is_used', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => true,'signed' => true,'comment' => '使用状态',])
  36. ->addColumn('brand', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => '品牌',])
  37. ->addColumn('supplier', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => '供应商',])
  38. ->addColumn('out_date', 'date', ['null' => true,'signed' => true,'comment' => '出厂日期',])
  39. ->addColumn('remark', 'string', ['limit' => 256,'null' => true,'signed' => true,'comment' => '备注',])
  40. ->addColumn('alarm_state', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => '告警状态',])
  41. ->addColumn('net_state', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => '网络状态',])
  42. ->addColumn('online_time', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => true,'signed' => true,'comment' => '在线时间',])
  43. ->addColumn('max_pressure', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => '最大压力',])
  44. ->addColumn('min_pressure', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => '最小压力',])
  45. ->addColumn('angle_sensor', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => '角度传感器',])
  46. ->addColumn('checked_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => true,'signed' => true,'comment' => '校验时间',])
  47. ->addColumn('checked_no', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => '校验台编号',])
  48. ->addColumn('checked_res', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => '校验结果',])
  49. ->addColumn('checked_user_id', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => '操作员',])
  50. ->addColumn('max_torque', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => '最大扭矩',])
  51. ->addColumn('min_torque', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => '最小扭矩',])
  52. ->addColumn('creator_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '创建人ID',])
  53. ->addColumn('created_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '创建时间',])
  54. ->addColumn('updated_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '更新时间',])
  55. ->addColumn('deleted_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '软删除',])
  56. ->create();
  57. }
  58. }