20220412045711_add_product_stock_field.php 828 B

1234567891011121314151617181920212223242526
  1. <?php
  2. declare (strict_types = 1);
  3. use Phinx\Migration\AbstractMigration;
  4. final class AddProductStockField extends AbstractMigration
  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. * https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
  13. *
  14. * Remember to call "create()" or "update()" and NOT "save()" when working
  15. * with the Table class.
  16. */
  17. public function change(): void
  18. {
  19. $table = $this->table('product');
  20. $table->addColumn('sales', 'integer', array('comment' => '商品销售数', 'after' => 'content'))
  21. ->addColumn('stock', 'integer', array('comment' => '商品库存', 'after' => 'content'))
  22. ->update();
  23. }
  24. }