pg support of duplicate key update

This commit is contained in:
xiaomlove
2026-04-25 03:22:38 +07:00
parent dc77ab7b40
commit 7d18a7f76a
14 changed files with 62 additions and 29 deletions
@@ -29,7 +29,7 @@ class MigrateTorrentsTableTextColumn extends Command
public function handle()
{
if (Schema::hasTable("torrent_extras") && Schema::hasColumn("torrents", "descr")) {
NexusDB::statement("insert into torrent_extras (torrent_id, descr, media_info, nfo, pt_gen, created_at) select id, descr, technical_info, nfo, pt_gen, now() from torrents on duplicate key update torrent_id = values(torrent_id)");
NexusDB::statement("insert into torrent_extras (torrent_id, descr, media_info, nfo, pt_gen, created_at) select id, descr, technical_info, nfo, pt_gen, now() from torrents " . NexusDB::upsertField(['torrent_id'], ['torrent_id']));
}
$columns = ["ori_descr", "descr", "nfo", "technical_info", "pt_gen"];
$sql = "alter table torrents ";