20220506141132_wrench.php 4.0 KB

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