You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
1.1KB

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