m181111_123134_create_goods_sku_table.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. use yii\db\Migration;
  3. use yii\db\Schema;
  4. /**
  5. * Handles the creation of table `{{%goods_sku}}`.
  6. */
  7. class m181111_123134_create_goods_sku_table extends Migration
  8. {
  9. public $tableOptions = 'CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE=InnoDB';
  10. /**
  11. * @inheritdoc
  12. */
  13. public function up()
  14. {
  15. $this->createTable('{{%goods_sku}}', [
  16. 'id' => Schema::TYPE_PK,
  17. 'goods_id' => Schema::TYPE_INTEGER . "(11) NOT NULL COMMENT '商品ID'",
  18. 'name' => Schema::TYPE_STRING . "(20) NOT NULL COMMENT '规格名称'",
  19. 'origin_price' => Schema::TYPE_DECIMAL . "(10,2) NOT NULL COMMENT '原价'",
  20. 'price' => Schema::TYPE_DECIMAL . "(10,2) NOT NULL COMMENT '售价'",
  21. 'stock' => Schema::TYPE_INTEGER . "(11) NOT NULL COMMENT '库存'",
  22. 'actual_sales' => Schema::TYPE_INTEGER . "(11) NOT NULL COMMENT '实际销量'",
  23. 'virtual_sales' => Schema::TYPE_INTEGER . "(11) NOT NULL COMMENT '虚拟销量'",
  24. 'created_at' => Schema::TYPE_INTEGER . "(11) NOT NULL",
  25. 'updated_at' => Schema::TYPE_INTEGER . "(11) NOT NULL",
  26. 'status' => Schema::TYPE_SMALLINT . "(1) NOT NULL DEFAULT '1' COMMENT '状态'",
  27. ]);
  28. }
  29. /**
  30. * @inheritdoc
  31. */
  32. public function down()
  33. {
  34. $this->dropTable('{{%goods_sku}}');
  35. }
  36. }