m160313_153426_session_init.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /**
  3. * @link http://www.yiiframework.com/
  4. * @copyright Copyright (c) 2008 Yii Software LLC
  5. * @license http://www.yiiframework.com/license/
  6. */
  7. use yii\db\Migration;
  8. /**
  9. * Initializes Session tables
  10. *
  11. * @author Misbahul D Munir <misbahuldmunir@gmail.com>
  12. * @since 2.0.8
  13. */
  14. class m160313_153426_session_init extends Migration
  15. {
  16. /**
  17. * @inheritdoc
  18. */
  19. public function up()
  20. {
  21. $tableOptions = null;
  22. if ($this->db->driverName === 'mysql') {
  23. // http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
  24. $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
  25. }
  26. $this->createTable('{{%session}}', [
  27. 'id' => $this->string()->notNull(),
  28. 'expire' => $this->integer(),
  29. 'data' => $this->binary(),
  30. 'PRIMARY KEY ([[id]])',
  31. ], $tableOptions);
  32. }
  33. /**
  34. * @inheritdoc
  35. */
  36. public function down()
  37. {
  38. $this->dropTable('{{%session}}');
  39. }
  40. }