M221214081051AddRecordToDiyComponents.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace app\migrations;
  3. use yii\db\Migration;
  4. /**
  5. *
  6. * Class M221214081051AddRecordToDiyComponents
  7. */
  8. class M221214081051AddRecordToDiyComponents extends Migration
  9. {
  10. /**
  11. * {@inheritdoc}
  12. */
  13. public function safeUp()
  14. {
  15. $sql = "select * from qimall_diy_components where code = 'micro-theme'";
  16. $res = $this->db->createCommand($sql)->execute();
  17. if($res) return '';
  18. $sql = 'INSERT INTO `qimall_diy_components` ( `code`, `title`, `group`, `icon`, `count`, `is_top`, `permission`, `sort`, `source`, `status`, `created_at`, `updated_at`) VALUES ( \'micro-theme\', \'轮播组件\', \'img_text\', \'\', \'1\', \'0\', \'{\"is_drag\":\"false\",\"is_up\":\"false\",\"id_down\":\"false\",\"is_copy\":\"false\"}\', \'999\', \'\', \'1\', \'1634538238\', \'1634538238\');';
  19. $this->execute($sql);
  20. }
  21. /**
  22. * {@inheritdoc}
  23. */
  24. public function safeDown()
  25. {
  26. echo "M221214081051AddRecordToDiyComponents cannot be reverted.\n";
  27. return false;
  28. }
  29. }