Skip to content

Commit 42f6e71

Browse files
committed
fix(migrate): skip bill type backfill when schema is missing
1 parent fa696cf commit 42f6e71

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

time_tracking/patches/post_model_sync/set_default_bill_type_on_time_bookings.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,28 @@
22

33

44
def execute():
5+
if not _has_bill_type_column():
6+
return
7+
58
frappe.db.sql(
69
"""
710
update `tabTime Booking`
811
set bill_type = 'Billable'
912
where ifnull(bill_type, '') = ''
1013
"""
1114
)
15+
16+
17+
def _has_bill_type_column():
18+
return bool(
19+
frappe.db.sql(
20+
"""
21+
select 1
22+
from information_schema.columns
23+
where table_schema = database()
24+
and table_name = 'tabTime Booking'
25+
and column_name = 'bill_type'
26+
limit 1
27+
"""
28+
)
29+
)

0 commit comments

Comments
 (0)