fix(postgres): add pg compatible query for copying comm_date from comm to comm_link (#35488)

This commit is contained in:
Aarol D'Souza 2026-01-04 10:18:53 +05:30 committed by GitHub
parent 5e2eab0cd8
commit 8d8fa78bee
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -6,18 +6,32 @@ def execute():
batch_size = 10_000
while True:
frappe.db.sql(
"""
update `tabCommunication Link` cl
inner join `tabCommunication` c on cl.parent = c.name
set cl.communication_date = c.communication_date
where cl.communication_date is null
and c.communication_date is not null
limit %s
""",
frappe.db.multisql(
{
"mariadb": """
update `tabCommunication Link` cl
inner join `tabCommunication` c on cl.parent = c.name
set cl.communication_date = c.communication_date
where cl.communication_date is null
and c.communication_date is not null
limit %s
""",
"postgres": """
UPDATE "tabCommunication Link"
SET communication_date = sub.communication_date
FROM (
SELECT cl.name, c.communication_date
FROM "tabCommunication Link" cl
JOIN "tabCommunication" c ON cl.parent = c.name
WHERE cl.communication_date IS NULL
AND c.communication_date IS NOT NULL
LIMIT %s
) AS sub
WHERE "tabCommunication Link".name = sub.name
""",
},
(batch_size,),
)
frappe.db.commit()
if not frappe.db.sql(