m170306_133529_create_url_rule_table.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. use yii\db\Migration;
  3. /**
  4. * Handles the creation for table `{{%url_rule}}`.
  5. */
  6. class m170306_133529_create_url_rule_table extends Migration
  7. {
  8. /**
  9. * @inheritdoc
  10. */
  11. public function up()
  12. {
  13. $this->createTable('{{%url_rule}}', [
  14. 'id' => $this->primaryKey(),
  15. 'name' => $this->string(50)->null(),
  16. 'pattern' => $this->string(255)->notNull(),
  17. 'host' => $this->string(255)->null(),
  18. 'route' => $this->string(255)->notNull(),
  19. 'defaults' => $this->string(255)->null(),
  20. 'suffix' => $this->string(255)->null(),
  21. 'verb' => $this->string(255)->null(),
  22. 'mode' => $this->boolean()->notNull()->defaultValue('0'),
  23. 'encodeParams' => $this->boolean()->notNull()->defaultValue('1'),
  24. 'status' => $this->smallInteger(1)->null()->defaultValue('1'),
  25. 'sort' => $this->smallInteger(1)->null()->defaultValue('1')->comment('排序'),
  26. ], "CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE=InnoDB");
  27. $this->batchInsert('{{%url_rule}}', ['pattern', 'route', 'suffix'], [
  28. ['<id:\d+>', '/article/view', '.html'],
  29. ['tag/search', 'tag/search', null],
  30. ]);
  31. }
  32. /**
  33. * @inheritdoc
  34. */
  35. public function down()
  36. {
  37. $this->dropTable('{{%url_rule}}');
  38. }
  39. }