Snippet content copied to clipboard.
Are you sure to delete this snippet? No, don't delete
  1. <?php
  2. use yii\db\Migration;
  3. /**
  4. * Handles the creation of table `{{%verification_auth}}`.
  5. */
  6. class m220323_084927_create_verification_auth_table extends Migration
  7. {
  8. /**
  9. * {@inheritdoc}
  10. */
  11. public function safeUp()
  12. {
  13. $tableOptions = null;
  14. if ($this->db->driverName === 'mysql') {
  15. $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
  16. }
  17. $this->createTable('{{%verification_auth}}', [
  18. 'hash' => $this->string(50),
  19. 'addressee' => $this->string(100),
  20. 'user_id' => $this->integer(11)->notNull(),
  21. 'verify_code' => $this->integer(11)->notNull(),
  22. 'created_at' => $this->integer(11)->notNull(),
  23. 'resend_at' => $this->integer(11)->notNull(),
  24. 'ip' => $this->string(128)->notNull(),
  25. 'is_confirmed' => $this->tinyInteger(1)->notNull()->defaultValue(0),
  26. 'attempts' => $this->integer(11)->notNull()->defaultValue(0)
  27. ], $tableOptions);
  28. $this->addPrimaryKey(
  29. 'pk-verification_auth-hash',
  30. 'verification_auth',
  31. 'hash'
  32. );
  33. $this->createIndex(
  34. 'user_id',
  35. 'verification_auth',
  36. 'user_id'
  37. );
  38. }
  39. /**
  40. * {@inheritdoc}
  41. */
  42. public function safeDown()
  43. {
  44. $this->dropTable('{{%verification_auth}}');
  45. }
  46. }

Edit this Snippet