20220120094737_devices.php 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. use think\migration\Migrator;
  3. use think\migration\db\Column;
  4. use Phinx\Db\Adapter\MysqlAdapter;
  5. class Devices 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('devices', ['engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '' ,'id' => 'id','signed' => true ,'primary_key' => ['id']]);
  31. $table->addColumn('imei', 'string', ['limit' => 20,'null' => true,'signed' => true,'comment' => 'GPS编号',])
  32. ->addColumn('rfid', 'string', ['limit' => 20,'null' => true,'signed' => true,'comment' => '标签编号',])
  33. ->addColumn('name', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '设备名称',])
  34. ->addColumn('alarm_state', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '告警状态',])
  35. ->addColumn('model', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '设备型号',])
  36. ->addColumn('bind_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '关联物体',])
  37. ->addColumn('department_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '所属部门',])
  38. ->addColumn('iccid', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => 'ICCID',])
  39. ->addColumn('scenario', 'string', ['limit' => 20,'null' => true,'signed' => true,'comment' => '应用场景',])
  40. ->addColumn('sim_no', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => 'SIM卡号',])
  41. ->addColumn('longitude', 'decimal', ['precision' => 10,'scale' => 6,'null' => true,'signed' => true,'comment' => '经度',])
  42. ->addColumn('latitude', 'decimal', ['precision' => 10,'scale' => 6,'null' => true,'signed' => true,'comment' => '纬度',])
  43. ->addColumn('loc_mode', 'string', ['limit' => 16,'null' => true,'signed' => true,'comment' => '定位类型',])
  44. ->addColumn('address', 'string', ['limit' => 200,'null' => true,'signed' => true,'comment' => '安装地址',])
  45. ->addColumn('online_time', 'datetime', ['null' => true,'signed' => true,'comment' => '在线时间',])
  46. ->addColumn('soft_ver', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '软件版本',])
  47. ->addColumn('hard_ver', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '硬件版本',])
  48. ->addColumn('remark', 'text', ['limit' => MysqlAdapter::TEXT_REGULAR,'null' => true,'signed' => true,'comment' => '备注',])
  49. ->addColumn('battery_level', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '电量',])
  50. ->addColumn('creator_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '创建人ID',])
  51. ->addColumn('created_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '创建时间',])
  52. ->addColumn('updated_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '更新时间',])
  53. ->addColumn('deleted_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '软删除',])
  54. ->create();
  55. }
  56. }