20221004103716_create_customer_portrait_field_table.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. use think\migration\Migrator;
  3. use think\migration\db\Column;
  4. class CreateCustomerPortraitFieldTable 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('customer_portrait_field', ['comment' => '客户画像字段', 'engine'=>'InnoDB']);
  30. $table->addColumn('name', 'string',array('comment'=>'字段名称'))
  31. ->addColumn('pid', 'integer',array('comment'=>'上级id','default'=>0))
  32. ->addColumn(Column::tinyInteger('type')->setComment('字段的类型,1输入框,2数字框,3单选框,4多选框,5日期')->setDefault(1))
  33. ->addColumn(Column::tinyInteger('isedit')->setComment('是否可编辑0是1否')->setDefault(0))
  34. ->addColumn(Column::tinyInteger('isdel')->setComment('是否可删除0是1否')->setDefault(0))
  35. ->addColumn('root_id', 'integer',array('comment'=>'公司id','default'=>1))
  36. ->addColumn('select', 'string',array('limit' =>2000,'comment'=>'选项','null' => true,'default'=>null))
  37. ->addColumn(Column::tinyInteger('status')->setComment('是否显示0是1否')->setDefault(0))
  38. ->addColumn('keyname', 'string',array('limit' =>255,'comment'=>'字段键名称','null' => true))
  39. ->addColumn('unity', 'string',array('comment'=>'单位','null'=>true))
  40. ->addColumn(Column::tinyInteger('is_status')->setComment('是否可编辑0是1否')->setDefault(0))
  41. ->addColumn(Column::tinyInteger('isedit_type')->setComment('是否可编辑填写方式0是1否')->setDefault(0))
  42. ->addColumn('sort', 'integer', array('comment' => '排序', 'null' => true))
  43. ->create();
  44. }
  45. }