20220428195332_fan.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. use think\migration\Migrator;
  3. use think\migration\db\Column;
  4. use Phinx\Db\Adapter\MysqlAdapter;
  5. class Fan 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('fan', ['engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '风机表' ,'id' => 'id','signed' => true ,'primary_key' => ['id']]);
  31. $table->addColumn('wind_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => true,'comment' => '风厂的id',])
  32. ->addColumn('number', 'string', ['limit' => 32,'null' => false,'default' => 0,'signed' => true,'comment' => '机位号',])
  33. ->addColumn('fan_model', 'string', ['limit' => 32,'null' => false,'default' => 0,'signed' => true,'comment' => '风机型号',])
  34. ->addColumn('supplier', 'string', ['limit' => 50,'null' => true,'signed' => true,'comment' => '供应商',])
  35. ->addColumn('out_date', 'date', ['null' => true,'signed' => true,'comment' => '出厂日期',])
  36. ->addColumn('address', 'string', ['limit' => 100,'null' => true,'signed' => true,'comment' => '地址',])
  37. ->addColumn('longitude', 'decimal', ['precision' => 10,'scale' => 6,'null' => true,'signed' => true,'comment' => '经度',])
  38. ->addColumn('latitude', 'decimal', ['precision' => 10,'scale' => 6,'null' => true,'signed' => true,'comment' => '纬度',])
  39. ->addColumn('info', 'string', ['limit' => 100,'null' => true,'signed' => true,'comment' => '备注',])
  40. ->addColumn('creator_id', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '创建人ID',])
  41. ->addColumn('created_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '创建时间',])
  42. ->addColumn('updated_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '更新时间',])
  43. ->addColumn('deleted_at', 'integer', ['limit' => MysqlAdapter::INT_REGULAR,'null' => false,'default' => 0,'signed' => false,'comment' => '软删除',])
  44. ->create();
  45. }
  46. }