mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-06-23 03:50:56 +08:00
修正chapter_user表中plan_id=0问题
This commit is contained in:
parent
59e27e1443
commit
486ac7bd69
@ -126,6 +126,7 @@ class ChapterInfo extends LogicService
|
||||
|
||||
$chapterUser = new ChapterUserModel();
|
||||
|
||||
$chapterUser->plan_id = $this->courseUser->plan_id;
|
||||
$chapterUser->course_id = $chapter->course_id;
|
||||
$chapterUser->chapter_id = $chapter->id;
|
||||
$chapterUser->user_id = $user->id;
|
||||
|
32
db/migrations/20240111185633.php
Normal file
32
db/migrations/20240111185633.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2024 深圳市酷瓜软件有限公司
|
||||
* @license https://opensource.org/licenses/GPL-2.0
|
||||
* @link https://www.koogua.com
|
||||
*/
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class V20240111185633 extends AbstractMigration
|
||||
{
|
||||
|
||||
public function up()
|
||||
{
|
||||
$this->handleChapterUsers();
|
||||
}
|
||||
|
||||
/**
|
||||
* 纠正 chapter_user 表中 plan_id = 0 的数据
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function handleChapterUsers()
|
||||
{
|
||||
$sql = 'UPDATE kg_chapter_user AS a JOIN kg_course_user AS b
|
||||
ON a.course_id = b.course_id AND a.user_id = b.user_id
|
||||
SET a.plan_id = b.plan_id WHERE a.plan_id = 0';
|
||||
|
||||
$this->query($sql);
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user