20220527120443_create_building_table.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. use think\migration\Migrator;
  3. use think\migration\db\Column;
  4. class CreateBuildingTable extends Migrator
  5. {
  6. /**
  7. * Change Method.
  8. *
  9. * Write your reversible migrations using this method.
  10. *
  11. * More information on writing migrations is available here:
  12. * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
  13. *
  14. * The following commands can be used in this method and Phinx will
  15. * automatically reverse them when rolling back:
  16. *
  17. * createTable
  18. * renameTable
  19. * addColumn
  20. * renameColumn
  21. * addIndex
  22. * addForeignKey
  23. *
  24. * Remember to call "create()" or "update()" and NOT "save()" when working
  25. * with the Table class.
  26. */
  27. public function change()
  28. {
  29. $table = $this->table('building')->setComment('vr楼书');
  30. $table->addColumn('name', 'string', ['limit'=> 255, 'comment'=> '小区名称', 'default'=> ''])
  31. ->addColumn('pinyin', 'string', ['limit'=> 255, 'comment'=> '小区名称拼音', 'default'=> ''])
  32. ->addColumn('address', 'string', ['limit'=> 255, 'comment'=> '小区地址', 'default'=> ''])
  33. ->addColumn('duetime', 'timestamp', ['default'=> null, 'comment'=> '交房时间'])
  34. ->addColumn('cover', 'string', ['limit'=> 255, 'comment'=> '小区封面', 'default'=> ''])
  35. ->addColumn('vr_link', 'text', ['comment'=> 'vr链接', 'default'=> null])
  36. ->addColumn('content', 'text', ['comment'=> '小区简介', 'default'=> null])
  37. ->addColumn('root_id', 'integer', ['comment'=> '组织id', 'default'=> 0])
  38. ->addColumn('addtime', 'timestamp', ['default'=> 'CURRENT_TIMESTAMP', 'comment'=> '添加时间'])
  39. ->addColumn('update_time', 'timestamp', ['default'=> 'CURRENT_TIMESTAMP', 'comment'=> '更新时间'])
  40. ->addColumn('shared_times', 'integer', ['default'=> 0, 'comment'=> '分享次数', 'limit'=> 10])
  41. ->addColumn(Column::tinyInteger('del')->setComment('是否删除,1删除')->setDefault(0))
  42. ->create();
  43. }
  44. }