m181105_061230_create_space_table.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. use yii\db\Migration;
  3. use yii\db\Schema;
  4. /**
  5. * Handles the creation of table `{{%space}}`.
  6. */
  7. class m181105_061230_create_space_table extends Migration
  8. { public $tableOptions = 'CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE=InnoDB';
  9. /**
  10. * @inheritdoc
  11. */
  12. public function up()
  13. {
  14. /**
  15. * 空间
  16. */
  17. $this->createTable('{{%space}}', [
  18. 'id' => Schema::TYPE_PK,
  19. 'name' => Schema::TYPE_STRING . "(20) NOT NULL COMMENT '名称'",
  20. 'desc' => Schema::TYPE_STRING . "(300) NOT NULL COMMENT '简介'",
  21. 'province' => Schema::TYPE_STRING . "(50) NOT NULL COMMENT '省份'",
  22. 'city' => Schema::TYPE_STRING . "(50) NOT NULL COMMENT '城市'",
  23. 'area' => Schema::TYPE_STRING . "(50) NOT NULL COMMENT '区域'",
  24. 'address' => Schema::TYPE_STRING . "(200) NOT NULL COMMENT '详细地址'",
  25. 'contacts' => Schema::TYPE_STRING . "(20) NOT NULL COMMENT '联系人'",
  26. 'tel' => Schema::TYPE_STRING . "(11) NOT NULL COMMENT '联系电话'",
  27. 'vid' => Schema::TYPE_STRING . "(32) NOT NULL COMMENT '腾讯视频vid'",
  28. 'created_at' => Schema::TYPE_INTEGER . "(11) NOT NULL",
  29. 'updated_at' => Schema::TYPE_INTEGER . "(11) NOT NULL",
  30. 'status' => Schema::TYPE_SMALLINT . "(1) NOT NULL DEFAULT '1' COMMENT '状态'",
  31. ], $this->tableOptions);
  32. }
  33. /**
  34. * @inheritdoc
  35. */
  36. public function down()
  37. {
  38. $this->dropTable('{{%space}}');
  39. }
  40. }