/migrations/m160614_231609_add_defaultRole_and_root_user.php

https://gitlab.com/Georgiy.Zhegusov/museum_documents · PHP · 63 lines · 46 code · 7 blank · 10 comment · 0 complexity · 3bb50dc054038329fb0fb22c17353dcc MD5 · raw file

  1. <?php
  2. use yii\db\Migration;
  3. class m160614_231609_add_defaultRole_and_root_user extends Migration
  4. {
  5. public function up()
  6. {
  7. $this->insert('groups', [
  8. 'id' => 1,
  9. 'name' => 'Всемогущий',
  10. 'level' => '4',
  11. 'role' => 'root',
  12. 'triggered' => 'false',
  13. ]);
  14. $this->insert('groups', [
  15. 'id' => 2,
  16. 'name' => 'Администратор',
  17. 'level' => '3',
  18. 'role' => 'admin',
  19. 'triggered' => 'false',
  20. ]);
  21. $this->insert('groups', [
  22. 'id' => 3,
  23. 'name' => 'Эксперт',
  24. 'level' => '1',
  25. 'role' => 'expert',
  26. 'triggered' => 'false',
  27. ]);
  28. $this->insert('users', [
  29. 'id' => 1,
  30. 'name' => 'Георгий',
  31. 'surname' => 'Жегусов',
  32. 'email' => 'gaur-@mail.ru',
  33. 'phone' => '89031867393',
  34. 'authKey' => 'CqDnVMGWs4N8uBqQU0Op1O5ER2NkiSkY',
  35. 'password' => crypt('123456789', "$5\$rounds=132000\$gaur-@mail.ru"),
  36. 'groupId' => 1,
  37. ]);
  38. }
  39. public function down()
  40. {
  41. $this->delete('users', ['id' => 1]);
  42. $this->delete('groups', ['id' => 3]);
  43. $this->delete('groups', ['id' => 2]);
  44. $this->delete('groups', ['id' => 1]);
  45. }
  46. /*
  47. // Use safeUp/safeDown to run migration code within a transaction
  48. public function safeUp()
  49. {
  50. }
  51. public function safeDown()
  52. {
  53. }
  54. */
  55. }