m160702_101410_create_module.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. use yii\db\Migration;
  3. /**
  4. * Handles the creation for table `{{%module}}`.
  5. */
  6. class m160702_101410_create_module extends Migration
  7. {
  8. /**
  9. * @inheritdoc
  10. */
  11. public function up()
  12. {
  13. $tableOptions = null;
  14. if ($this->db->driverName === 'mysql') {
  15. $tableOptions = 'CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE=InnoDB';
  16. }
  17. $this->createTable('{{%module}}', [
  18. 'id' => $this->string(50)->notNull()->unique()->comment('标识'),
  19. 'name' => $this->string(50)->notNull(),
  20. 'bootstrap' => $this->string(128)->comment('模块初始化应用ID'),
  21. 'status' => $this->smallInteger(1)->notNull(),
  22. 'type' => $this->smallInteger(1)->notNull()->comment('模块类型1module2plugin'),
  23. 'config' => $this->text()->comment('配置'),
  24. 'created_at' => $this->integer(10)->notNull(),
  25. 'updated_at' => $this->integer(10)->notNull(),
  26. ], $tableOptions);
  27. $this->addPrimaryKey('id', '{{%module}}', 'id');
  28. }
  29. /**
  30. * @inheritdoc
  31. */
  32. public function down()
  33. {
  34. $this->dropTable('{{%module}}');
  35. }
  36. }