20220303142809_hydraulic.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. use think\migration\Migrator;
  3. use think\migration\db\Column;
  4. use Phinx\Db\Adapter\MysqlAdapter;
  5. class Hydraulic 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('hydraulic', ['engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '' ,'id' => 'id','signed' => true ,'primary_key' => ['id']]);
  31. //基础信息
  32. $table->addColumn('number', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '编号',])
  33. ->addColumn('model', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '型号',])
  34. ->addColumn('department_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => true,'signed' => true,'comment' => '所属部门',])
  35. ->addColumn('name', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '名称',])
  36. ->addColumn('is_used', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '使用状态',])
  37. ->addColumn('brand', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '品牌',])
  38. ->addColumn('supplier', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '供应商',])
  39. ->addColumn('out_date', 'date', ['null' => true,'signed' => true,'comment' => '出厂日期',])
  40. ->addColumn('remark', 'string', ['limit' => 255,'null' => true,'signed' => true,'comment' => '备注',])
  41. ->addColumn('type', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '设备类型',])
  42. ->addColumn('alarm_state', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '告警状态',])
  43. ->addColumn('net_state', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '网络状态',])
  44. ->addColumn('online_time', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => true,'default' => null,'signed' => true,'comment' => '在线时间',])
  45. ->addColumn('creator_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '创建人ID',])
  46. ->addColumn('created_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '创建时间',])
  47. ->addColumn('updated_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '更新时间',])
  48. ->addColumn('deleted_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '软删除',])
  49. //液压泵规格信息
  50. ->addColumn('pressure_range', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '压力范围(PSI)',])
  51. //液压扳手实时维保信息
  52. ->addColumn('coefficient_a', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '校准系数a',])
  53. ->addColumn('coefficient_b', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '校准系数b',])
  54. ->addColumn('checked_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '校验时间',])
  55. ->addColumn('checked_no', 'string', ['limit' => 50,'null' => true,'default' => null,'signed' => false,'comment' => '校验台编号',])
  56. ->addColumn('checked_res', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '校验结果',])
  57. ->addColumn('checked_user_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'comment' => '操作员',])
  58. //法兰规格信息
  59. ->addColumn('diameter', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '直径',])
  60. ->addColumn('bolts_num', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '螺栓数量',])
  61. ->addColumn('bolts_size', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '螺栓尺寸',])
  62. ->addColumn('preload', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '标准预紧力',])
  63. ->create();
  64. }
  65. }