M221215092022AddCategoryToLinkCategory.php 1.5 KB

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