m181105_023343_create_store_table.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. use yii\db\Migration;
  3. use yii\db\Schema;
  4. /**
  5. * Handles the creation of table `{{%store}}`.
  6. */
  7. class m181105_023343_create_store_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. /**
  16. * 商品分类
  17. */
  18. $this->createTable('{{%store}}', [
  19. 'id' => Schema::TYPE_PK,
  20. 'user_id' => Schema::TYPE_INTEGER . "(11) NOT NULL COMMENT '店家账户'",
  21. 'proxy_user_id' => Schema::TYPE_INTEGER . "(11) NOT NULL COMMENT '代理人'",
  22. 'name' => Schema::TYPE_STRING . "(20) NOT NULL COMMENT '名称'",
  23. 'contacts' => Schema::TYPE_STRING . "(20) NOT NULL DEFAULT '' COMMENT '联系人'",
  24. 'tel' => Schema::TYPE_STRING . "(11) NOT NULL DEFAULT '' COMMENT '联系电话'",
  25. 'address' => Schema::TYPE_STRING . "(200) NOT NULL DEFAULT '' COMMENT '地址'",
  26. 'address_name' => Schema::TYPE_STRING . "(200) NOT NULL DEFAULT '' COMMENT '地址'",
  27. 'city' => Schema::TYPE_STRING . "(100) NOT NULL DEFAULT '' COMMENT '城市'",
  28. 'longitude' => Schema::TYPE_DECIMAL . "(10,7) NOT NULL DEFAULT '0' COMMENT '经度'",
  29. 'latitude' => Schema::TYPE_DECIMAL . "(10,7) NOT NULL DEFAULT '' COMMENT '纬度'",
  30. 'desc' => Schema::TYPE_STRING . "(300) NOT NULL DEFAULT '' COMMENT '简介'",
  31. 'created_at' => Schema::TYPE_INTEGER . "(11) NOT NULL",
  32. 'updated_at' => Schema::TYPE_INTEGER . "(11) NOT NULL",
  33. 'status' => Schema::TYPE_SMALLINT . "(1) NOT NULL DEFAULT '1' COMMENT '状态'",
  34. ], $this->tableOptions);
  35. }
  36. /**
  37. * @inheritdoc
  38. */
  39. public function down()
  40. {
  41. $this->dropTable('{{%store}}');
  42. }
  43. }