m181105_151442_create_master_table.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. use yii\db\Migration;
  3. use yii\db\Schema;
  4. /**
  5. * Handles the creation of table `{{%master}}`.
  6. */
  7. class m181105_151442_create_master_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('{{%master}}', [
  19. 'id' => Schema::TYPE_PK,
  20. 'name' => Schema::TYPE_STRING . "(20) NOT NULL COMMENT '名称'",
  21. 'desc' => Schema::TYPE_STRING . "(300) NOT NULL COMMENT '简介'",
  22. 'province' => Schema::TYPE_STRING . "(50) NOT NULL COMMENT '省份'",
  23. 'city' => Schema::TYPE_STRING . "(50) NOT NULL COMMENT '城市'",
  24. 'area' => Schema::TYPE_STRING . "(50) NOT NULL COMMENT '区域'",
  25. 'address' => Schema::TYPE_STRING . "(200) NOT NULL COMMENT '详细地址'",
  26. 'fields' => Schema::TYPE_STRING . "(20) NOT NULL COMMENT '领域'",
  27. 'works' => Schema::TYPE_STRING . "(200) NOT NULL COMMENT '代表作'",
  28. 'tel' => Schema::TYPE_STRING . "(11) NOT NULL COMMENT '联系电话'",
  29. 'vid' => Schema::TYPE_STRING . "(32) NOT NULL COMMENT '腾讯视频vid'",
  30. 'created_at' => Schema::TYPE_INTEGER . "(11) NOT NULL",
  31. 'updated_at' => Schema::TYPE_INTEGER . "(11) NOT NULL",
  32. 'status' => Schema::TYPE_SMALLINT . "(1) NOT NULL DEFAULT '1' COMMENT '状态'",
  33. ], $this->tableOptions);
  34. }
  35. /**
  36. * @inheritdoc
  37. */
  38. public function down()
  39. {
  40. $this->dropTable('{{%master}}');
  41. }
  42. }