| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- <?php
- namespace app\migrations;
- use yii\db\Migration;
- /**
- * Class M240806035734UpdateQimallAddonsStoreMenuAndMchMenu
- */
- class M240806035734UpdateQimallAddonsStoreMenuAndMchMenu extends Migration
- {
- /**
- * {@inheritdoc}
- */
- public function safeUp()
- {
- try {
- // 检查并删除 qimall_addons_store_menu 表中的记录
- $checkStoreMenuSql = "
- SELECT COUNT(*)
- FROM information_schema.tables
- WHERE table_schema = DATABASE() AND table_name = 'qimall_addons_store_menu'
- ";
- $tableExists = $this->db->createCommand($checkStoreMenuSql)->queryScalar() > 0;
- if ($tableExists) {
- $this->execute("
- DELETE FROM `qimall_addons_store_menu`
- WHERE `title` = '打印日志';
- ");
- } else {
- echo "Table 'qimall_addons_store_menu' does not exist.\n";
- }
- // 检查并删除 qimall_addons_mch_menu 表中的记录
- $checkMchMenuSql = "
- SELECT COUNT(*)
- FROM information_schema.tables
- WHERE table_schema = DATABASE() AND table_name = 'qimall_addons_mch_menu'
- ";
- $tableExists = $this->db->createCommand($checkMchMenuSql)->queryScalar() > 0;
- if ($tableExists) {
- $this->execute("
- DELETE FROM `qimall_addons_mch_menu`
- WHERE `title` = '打印日志';
- ");
- } else {
- echo "Table 'qimall_addons_mch_menu' does not exist.\n";
- }
- } catch (\Exception $e) {
- echo "Failed to delete record: " . $e->getMessage() . "\n";
- return true;
- }
- }
- /**
- * {@inheritdoc}
- */
- public function safeDown()
- {
- echo "M240806035734UpdateQimallAddonsStoreMenuAndMchMenu cannot be reverted.\n";
- return false;
- }
- /*
- // Use up()/down() to run migration code without a transaction.
- public function up()
- {
- }
- public function down()
- {
- echo "M240806035734UpdateQimallAddonsStoreMenuAndMchMenu cannot be reverted.\n";
- return false;
- }
- */
- }
|