M250702095957InsertQimallLinkCategory.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. namespace addons\Store\console\migrations;
  3. use yii\db\Migration;
  4. /**
  5. * Class M250702095957InsertQimallLinkCategory
  6. */
  7. class M250702095957InsertQimallLinkCategory extends Migration
  8. {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. public function safeUp()
  13. {
  14. $sql = "INSERT INTO `qimall_link_category` ( `name`, `title`, `pid`, `is_list`, `remark`, `status`, `created_at`, `updated_at`) VALUES
  15. ( 'store_steward', '门店管家', 0, 0, NULL, 1, 1639814497, 1640312920);";
  16. $this->execute($sql);
  17. $sql = "select * from qimall_link_category where name = 'store_steward'";
  18. $list = \Yii::$app->db->createCommand($sql)->queryAll();
  19. if($list){
  20. $sql = "INSERT INTO `qimall_link_category` ( `name`, `title`, `pid`, `is_list`, `remark`, `status`, `created_at`, `updated_at`) VALUES ('diy_template', '装修页面', ".$list[0]['id'].", 1, NULL, 1, 1639814136, 1639814255);";
  21. $this->execute($sql);
  22. }
  23. }
  24. /**
  25. * {@inheritdoc}
  26. */
  27. public function safeDown()
  28. {
  29. echo "M250702095957InsertQimallLinkCategory cannot be reverted.\n";
  30. return false;
  31. }
  32. /*
  33. // Use up()/down() to run migration code without a transaction.
  34. public function up()
  35. {
  36. }
  37. public function down()
  38. {
  39. echo "M250702095957InsertQimallLinkCategory cannot be reverted.\n";
  40. return false;
  41. }
  42. */
  43. }