m181106_091332_create_goods_table.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. use yii\db\Migration;
  3. use yii\db\Schema;
  4. /**
  5. * Handles the creation of table `{{%goods}}`.
  6. */
  7. class m181106_091332_create_goods_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}}', [
  16. 'id' => Schema::TYPE_PK,
  17. 'category_id' => Schema::TYPE_INTEGER . "(11) NOT NULL COMMENT '分类ID'",
  18. 'store_id' => Schema::TYPE_INTEGER . "(11) NOT NULL COMMENT '供应商ID'",
  19. 'name' => Schema::TYPE_STRING . "(50) NOT NULL COMMENT '名称'",
  20. 'desc' => Schema::TYPE_STRING . "(200) NOT NULL COMMENT '描述'",
  21. 'actual_sales' => Schema::TYPE_STRING . "(200) NOT NULL COMMENT '实际销量'",
  22. 'virtual_sales' => Schema::TYPE_STRING . "(200) NOT NULL COMMENT '虚拟销量'",
  23. 'created_at' => Schema::TYPE_INTEGER . "(11) NOT NULL",
  24. 'updated_at' => Schema::TYPE_INTEGER . "(11) NOT NULL",
  25. 'status' => Schema::TYPE_SMALLINT . "(1) NOT NULL DEFAULT '1' COMMENT '状态'",
  26. ]);
  27. }
  28. /**
  29. * @inheritdoc
  30. */
  31. public function down()
  32. {
  33. $this->dropTable('{{%goods}}');
  34. }
  35. }