M230708085948InsertLinkCategoryMch.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace app\migrations;
  3. use yii\db\Migration;
  4. /**
  5. * Class M230708085948InsertLinkCategoryMch
  6. */
  7. class M230708085948InsertLinkCategoryMch extends Migration
  8. {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public function safeUp()
  13. {
  14. $sql = "select * from qimall_link_category where name = 'mch'";
  15. $res = $this->db->createCommand($sql)->execute();
  16. if(!$res){
  17. $sql = "INSERT INTO `qimall_link_category` (`name`, `title`, `pid`, `is_list`, `remark`, `status`, `created_at`, `updated_at`) VALUES ('mch', '多商户门店', '19', '1', NULL, '1', '1654741229', '1654741229');";
  18. $this->execute($sql);
  19. }
  20. $sql = "select * from qimall_link_category where name = 'mch_cate'";
  21. $res = $this->db->createCommand($sql)->execute();
  22. if(!$res){
  23. $sql = "INSERT INTO `qimall_link_category` (`name`, `title`, `pid`, `is_list`, `remark`, `status`, `created_at`, `updated_at`) VALUES ('mch_cate', '多商户门店分类', '19', '1', NULL, '1', '1654741255', '1654741345');";
  24. $this->execute($sql);
  25. }
  26. }
  27. /**
  28. * {@inheritdoc}
  29. */
  30. public function safeDown()
  31. {
  32. echo "M230708085948InsertLinkCategoryMch cannot be reverted.\n";
  33. return false;
  34. }
  35. /*
  36. // Use up()/down() to run migration code without a transaction.
  37. public function up()
  38. {
  39. }
  40. public function down()
  41. {
  42. echo "M230708085948InsertLinkCategoryMch cannot be reverted.\n";
  43. return false;
  44. }
  45. */
  46. }