20221115062406_create_customer_sharing_table.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. use think\migration\Migrator;
  3. class CreateCustomerSharingTable extends Migrator
  4. {
  5. /**
  6. * Change Method.
  7. *
  8. * Write your reversible migrations using this method.
  9. *
  10. * More information on writing migrations is available here:
  11. * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
  12. *
  13. * The following commands can be used in this method and Phinx will
  14. * automatically reverse them when rolling back:
  15. *
  16. * createTable
  17. * renameTable
  18. * addColumn
  19. * renameColumn
  20. * addIndex
  21. * addForeignKey
  22. *
  23. * Remember to call "create()" or "update()" and NOT "save()" when working
  24. * with the Table class.
  25. */
  26. public function change()
  27. {
  28. $table = $this->table('customer_sharing', ['id' => false, 'primary_key' => ['customer_id', 'employee_id']]);
  29. $table->addColumn('customer_id', 'integer', ['comment' => '客户id'])
  30. ->addColumn('employee_id', 'integer', ['comment' => '员工id'])
  31. ->addColumn('root_id', 'integer', ['comment' => '所属企业id'])
  32. ->addColumn('addtime', 'integer', ['comment' => '添加时间'])
  33. ->create();
  34. }
  35. }