m160702_101410_create_plugin.php 1012 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. use yii\db\Migration;
  3. /**
  4. * Handles the creation for table `{{%plugin}}`.
  5. */
  6. class m160702_101410_create_plugin 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('{{%plugin}}', [
  18. 'id' => $this->string(50)->comment('标识'),
  19. 'name' => $this->string(50)->notNull(),
  20. 'description' => $this->string(128),
  21. 'status' => $this->smallInteger(1)->notNull(),
  22. 'config' => $this->text()->comment('配置'),
  23. 'created_at' => $this->integer(10)->notNull(),
  24. 'updated_at' => $this->integer(10)->notNull(),
  25. 'PRIMARY KEY (`id`)'
  26. ], $tableOptions);
  27. }
  28. /**
  29. * @inheritdoc
  30. */
  31. public function down()
  32. {
  33. $this->dropTable('{{%plugin}}');
  34. }
  35. }