fix(postgres): add pg compatible query for copying comm_date from comm to comm_link (#35488)
This commit is contained in:
parent
5e2eab0cd8
commit
8d8fa78bee
1 changed files with 24 additions and 10 deletions
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue