1
0

m130524_201442_init.php 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. use yii\db\Migration;
  3. class m130524_201442_init extends Migration
  4. {
  5. public function up()
  6. {
  7. $tableOptions = null;
  8. if ($this->db->driverName === 'mysql') {
  9. // http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
  10. $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
  11. }
  12. $this->createTable('{{%user}}', [
  13. 'id' => $this->primaryKey(),
  14. 'username' => $this->string()->notNull()->unique(),
  15. 'auth_key' => $this->string(32)->notNull(),
  16. 'password_hash' => $this->string()->notNull(),
  17. 'password_reset_token' => $this->string()->unique(),
  18. 'email' => $this->string()->notNull()->unique(),
  19. 'status' => $this->smallInteger()->notNull()->defaultValue(10),
  20. 'created_at' => $this->integer()->notNull(),
  21. 'updated_at' => $this->integer()->notNull(),
  22. ], $tableOptions);
  23. }
  24. public function down()
  25. {
  26. $this->dropTable('{{%user}}');
  27. }
  28. }