Guest User

Untitled

a guest
Jun 21st, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. <?php
  2.  
  3. use yii\db\Migration;
  4.  
  5. /**
  6. * Class m180620_034536_auth
  7. */
  8. class m180620_034536_auth extends Migration
  9. {
  10. /**
  11. * {@inheritdoc}
  12. */
  13. public function safeUp()
  14. {
  15. $this->createTable('user', [
  16. 'id' => $this->primaryKey(),
  17. 'username' => $this->string()->notNull(),
  18. 'auth_key' => $this->string()->notNull(),
  19. 'password_hash' => $this->string()->notNull(),
  20. 'password_reset_token' => $this->string(),
  21. 'email' => $this->string()->notNull(),
  22. 'status' => $this->smallInteger()->notNull()->defaultValue(10),
  23. 'created_at' => $this->integer()->notNull(),
  24. 'updated_at' => $this->integer()->notNull(),
  25. ]);
  26.  
  27. $this->createTable('auth', [
  28. 'id' => $this->primaryKey(),
  29. 'user_id' => $this->integer()->notNull(),
  30. 'source' => $this->string()->notNull(),
  31. 'source_id' => $this->string()->notNull(),
  32. ]);
  33.  
  34. $this->addForeignKey('fk-auth-user_id-user-id', 'auth', 'user_id', 'user', 'id', 'CASCADE', 'CASCADE');
  35. }
  36.  
  37. /**
  38. * {@inheritdoc}
  39. */
  40. public function safeDown()
  41. {
  42. $this->dropTable('auth');
  43. $this->dropTable('user');
  44. }
  45.  
  46. /*
  47. // Use up()/down() to run migration code without a transaction.
  48. public function up()
  49. {
  50.  
  51. }
  52.  
  53. public function down()
  54. {
  55. echo "m180620_034536_auth cannot be reverted.\n";
  56.  
  57. return false;
  58. }
  59. */
  60. }
Add Comment
Please, Sign In to add comment