20220124125217_devices_add_fields.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CatchAdmin [Just Like ~ ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2017~{$year} http://catchadmin.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( https://github.com/yanwenwu/catch-admin/blob/master/LICENSE.txt )
  8. // +----------------------------------------------------------------------
  9. // | Author: JaguarJack [ njphper@gmail.com ]
  10. // +----------------------------------------------------------------------
  11. use think\migration\Migrator;
  12. use think\migration\db\Column;
  13. use Phinx\Db\Adapter\MysqlAdapter;
  14. class DevicesAddFields extends Migrator
  15. {
  16. /**
  17. * Change Method.
  18. *
  19. * Write your reversible migrations using this method.
  20. *
  21. * More information on writing migrations is available here:
  22. * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
  23. *
  24. * The following commands can be used in this method and Phinx will
  25. * automatically reverse them when rolling back:
  26. *
  27. * createTable
  28. * renameTable
  29. * addColumn
  30. * renameColumn
  31. * addIndex
  32. * addForeignKey
  33. *
  34. * Remember to call "create()" or "update()" and NOT "save()" when working
  35. * with the Table class.
  36. */
  37. public function change()
  38. {
  39. $table = $this->table('devices', ['engine' => 'InnoDB', 'comment' => '' ,'id' => 'id','signed' => true ,'primary_key' => ['id']]);
  40. $table->addColumn('loc_ploy_state', 'string', ['limit' => 8,'null' => true,'signed' => true,'default' =>1,'comment' => '定位策略状态,默认追踪模式已生效',])
  41. ->addColumn('wifi_macs', 'string', ['limit' => 128,'null' => true,'signed' => true,'comment' => 'WiFi Mac',])
  42. ->addColumn('wifi_online_time', 'datetime', ['null' => true,'signed' => true,'comment' => 'wifi在线时间',])
  43. ->addColumn('wifi_longitude', 'decimal', ['precision' => 10,'scale' => 6,'null' => true,'signed' => true,'comment' => 'wifi经度',])
  44. ->addColumn('wifi_latitude', 'decimal', ['precision' => 10,'scale' => 6,'null' => true,'signed' => true,'comment' => 'wifi纬度',])
  45. ->update();
  46. }
  47. }