20220303142809_hydraulic.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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-06-21 16:40:42
  9. */
  10. use think\migration\Migrator;
  11. use think\migration\db\Column;
  12. use Phinx\Db\Adapter\MysqlAdapter;
  13. class Hydraulic 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('hydraulic', ['engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '' ,'id' => 'id','signed' => true ,'primary_key' => ['id']]);
  39. //基础信息
  40. $table->addColumn('number', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '编号',])
  41. ->addColumn('department_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => true,'signed' => true,'comment' => '所属部门',])
  42. ->addColumn('remark', 'string', ['limit' => 255,'null' => true,'signed' => true,'comment' => '备注',])
  43. ->addColumn('alarm_state', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '告警状态',])
  44. ->addColumn('net_state', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '网络状态',])
  45. ->addColumn('online_time', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => true,'default' => null,'signed' => true,'comment' => '在线时间',])
  46. //液压泵规格信息
  47. ->addColumn('max_pressure', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => '最大压力',])
  48. ->addColumn('min_pressure', 'string', ['limit' => 32,'null' => true,'signed' => true,'comment' => '最小压力',])
  49. ->addColumn('longitude', 'decimal', ['precision' => 10,'scale' => 6,'null' => true,'signed' => true,'comment' => '经度',])
  50. ->addColumn('latitude', 'decimal', ['precision' => 10,'scale' => 6,'null' => true,'signed' => true,'comment' => '纬度',])
  51. ->addColumn('creator_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '创建人ID',])
  52. ->addColumn('created_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '创建时间',])
  53. ->addColumn('updated_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '更新时间',])
  54. ->addColumn('deleted_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '软删除',])
  55. ->create();
  56. }
  57. }