20220120100954_stations.php 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. use think\migration\Migrator;
  3. use think\migration\db\Column;
  4. use Phinx\Db\Adapter\MysqlAdapter;
  5. class Stations 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('stations', ['engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '' ,'id' => 'id','signed' => true ,'primary_key' => ['id']]);
  31. $table->addColumn('mac', 'string', ['limit' => 20,'null' => true,'signed' => true,'comment' => '基站Mac',])
  32. ->addColumn('shortcode', 'string', ['limit' => 20,'null' => true,'signed' => true,'comment' => '基站简码',])
  33. ->addColumn('name', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '基站名称',])
  34. ->addColumn('model', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '基站型号',])
  35. ->addColumn('serial_number', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '基站序列号',])
  36. ->addColumn('department_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '所属部门',])
  37. ->addColumn('version', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '版本号',])
  38. ->addColumn('open_status', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '开局状态',])
  39. ->addColumn('sim_no', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => 'SIM卡号',])
  40. ->addColumn('longitude', 'decimal', ['precision' => 10,'scale' => 0,'null' => true,'signed' => true,'comment' => '经度',])
  41. ->addColumn('latitude', 'decimal', ['precision' => 10,'scale' => 0,'null' => true,'signed' => true,'comment' => '纬度',])
  42. ->addColumn('online_time', 'datetime', ['null' => true,'signed' => true,'comment' => '在线时间',])
  43. ->addColumn('address', 'string', ['limit' => 200,'null' => true,'signed' => true,'comment' => '安装地址',])
  44. ->addColumn('remark', 'text', ['limit' => MysqlAdapter::TEXT_REGULAR,'null' => true,'signed' => true,'comment' => '备注',])
  45. ->addColumn('open_time', 'datetime', ['null' => true,'signed' => true,'comment' => '开局时间',])
  46. ->addColumn('open_user_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => true,'signed' => true,'comment' => '开局用户',])
  47. ->addColumn('creator_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '创建人ID',])
  48. ->addColumn('created_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '创建时间',])
  49. ->addColumn('updated_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '更新时间',])
  50. ->addColumn('deleted_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '软删除',])
  51. ->create();
  52. }
  53. }