|
@@ -35,6 +35,9 @@ class SyncAlbumContent extends Command
|
|
|
*/
|
|
|
public function handle()
|
|
|
{
|
|
|
+ exit;
|
|
|
+ $this->migrateAlbumLogToSiteAlbumLog();
|
|
|
+ exit;
|
|
|
// 任务1: 同步 cover 字段
|
|
|
$albumPaths = DB::table('album_path')->get();
|
|
|
|
|
@@ -97,4 +100,39 @@ class SyncAlbumContent extends Command
|
|
|
$this->info('Sync completed successfully.');
|
|
|
return 0;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ function migrateAlbumLogToSiteAlbumLog()
|
|
|
+ {
|
|
|
+ // 获取所有album_log记录
|
|
|
+ $albumLogs = DB::table('album_log')->get();
|
|
|
+
|
|
|
+ $migrationData = [];
|
|
|
+ foreach ($albumLogs as $log) {
|
|
|
+ // 根据model获取site_album对应的id
|
|
|
+ $siteAlbumId = DB::table('site_album')
|
|
|
+ ->where('model', $log->model)
|
|
|
+ ->value('id');
|
|
|
+
|
|
|
+ if ($siteAlbumId) {
|
|
|
+ $migrationData[] = [
|
|
|
+ 'user_name' => $log->user_name,
|
|
|
+ 'action' => $log->action,
|
|
|
+ 'model' => $log->model,
|
|
|
+ 'content' => $log->content,
|
|
|
+ 'content_id' => $siteAlbumId,
|
|
|
+ 'created_at' => $log->created_at,
|
|
|
+ 'updated_at' => $log->updated_at
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 批量插入数据
|
|
|
+ if (!empty($migrationData)) {
|
|
|
+ DB::table('site_album_log')->insert($migrationData);
|
|
|
+ }
|
|
|
+
|
|
|
+ return '迁移完成,共处理'.count($migrationData).'条记录';
|
|
|
+ }
|
|
|
}
|