M230717091035InsertIntoMenu.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. namespace app\migrations;
  3. use yii\db\Migration;
  4. /**
  5. * Class M230717091035InsertIntoMenu
  6. */
  7. class M230717091035InsertIntoMenu extends Migration
  8. {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public function safeUp()
  13. {
  14. $list = $this->db->createCommand("select * from qimall_menu where title like '%关注回复%' ")->queryAll();
  15. if($list) return true;
  16. $this->insert('qimall_menu',[
  17. 'title'=>'关注回复',
  18. 'app_id'=>'backend',
  19. 'cate_id'=>'2',
  20. 'addons_name'=>'',
  21. 'is_addon'=>'0',
  22. 'pid'=>'77',
  23. 'url'=>'mall/wechat/follow-reply-rule',
  24. 'icon'=>'',
  25. 'level'=>'3',
  26. 'dev'=>'3',
  27. 'sort'=>'999',
  28. //'params'=>'',
  29. 'tree'=>'tr_39 tr_77',
  30. 'status'=>'1',
  31. 'created_at'=>1631687277,
  32. 'updated_at'=>1631687277,
  33. ]);
  34. $this->insert('qimall_rbac_auth_item',[
  35. 'name'=>'mall/wechat/follow-reply-rule',
  36. 'title'=>'关注回复',
  37. 'app_id'=>'backend',
  38. 'addons_name'=>'',
  39. 'pid'=>'2824',
  40. 'level'=>'2',
  41. 'is_addon'=>'0',
  42. 'sort'=>'999',
  43. 'tree'=>'tr_0 tr_2824',
  44. 'status'=>'1',
  45. 'cate_id'=>'2',
  46. 'created_at'=>1631687277,
  47. 'updated_at'=>1631687277,
  48. ]);
  49. }
  50. /**
  51. * {@inheritdoc}
  52. */
  53. public function safeDown()
  54. {
  55. echo "M230717091035InsertIntoMenu cannot be reverted.\n";
  56. return false;
  57. }
  58. /*
  59. // Use up()/down() to run migration code without a transaction.
  60. public function up()
  61. {
  62. }
  63. public function down()
  64. {
  65. echo "M230717091035InsertIntoMenu cannot be reverted.\n";
  66. return false;
  67. }
  68. */
  69. }