Cadara_Ramirez

compare tables

Feb 28th, 2022 (edited)
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 29.73 KB | None | 0 0
  1. import frappe
  2.  
  3. # tables that should have rows
  4. res_production = [{'database_name': 'production',
  5. 'table_name': 'tabAccess Log',
  6. 'table_rows': 21914},
  7. {'database_name': 'production',
  8. 'table_name': 'tabAccount',
  9. 'table_rows': 2836},
  10. {'database_name': 'production',
  11. 'table_name': 'tabAccounting Dimension',
  12. 'table_rows': 1},
  13. {'database_name': 'production',
  14. 'table_name': 'tabAccounting Dimension Detail',
  15. 'table_rows': 1},
  16. {'database_name': 'production',
  17. 'table_name': 'tabActivity Log',
  18. 'table_rows': 124867},
  19. {'database_name': 'production',
  20. 'table_name': 'tabAddress',
  21. 'table_rows': 12715},
  22. {'database_name': 'production',
  23. 'table_name': 'tabAddress Template',
  24. 'table_rows': 2},
  25. {'database_name': 'production',
  26. 'table_name': 'tabAppraisal',
  27. 'table_rows': 37},
  28. {'database_name': 'production',
  29. 'table_name': 'tabAppraisal Goal',
  30. 'table_rows': 326},
  31. {'database_name': 'production',
  32. 'table_name': 'tabAppraisal Template',
  33. 'table_rows': 16},
  34. {'database_name': 'production',
  35. 'table_name': 'tabAppraisal Template Goal',
  36. 'table_rows': 119},
  37. {'database_name': 'production', 'table_name': 'tabAsset', 'table_rows': 2},
  38. {'database_name': 'production',
  39. 'table_name': 'tabAsset Category',
  40. 'table_rows': 6},
  41. {'database_name': 'production',
  42. 'table_name': 'tabAsset Category Account',
  43. 'table_rows': 6},
  44. {'database_name': 'production',
  45. 'table_name': 'tabAsset Finance Book',
  46. 'table_rows': 13},
  47. {'database_name': 'production',
  48. 'table_name': 'tabAsset Movement',
  49. 'table_rows': 1},
  50. {'database_name': 'production',
  51. 'table_name': 'tabAsset Movement Item',
  52. 'table_rows': 1},
  53. {'database_name': 'production',
  54. 'table_name': 'tabAttendance',
  55. 'table_rows': 1768},
  56. {'database_name': 'production', 'table_name': 'tabBank', 'table_rows': 2},
  57. {'database_name': 'production',
  58. 'table_name': 'tabBank Account',
  59. 'table_rows': 3},
  60. {'database_name': 'production', 'table_name': 'tabBatch', 'table_rows': 2},
  61. {'database_name': 'production', 'table_name': 'tabBin', 'table_rows': 4743},
  62. {'database_name': 'production', 'table_name': 'tabBOM', 'table_rows': 544},
  63. {'database_name': 'production',
  64. 'table_name': 'tabBOM Explosion Item',
  65. 'table_rows': 3334},
  66. {'database_name': 'production',
  67. 'table_name': 'tabBOM Item',
  68. 'table_rows': 3104},
  69. {'database_name': 'production', 'table_name': 'tabBranch', 'table_rows': 38},
  70. {'database_name': 'production', 'table_name': 'tabBrand', 'table_rows': 11},
  71. {'database_name': 'production', 'table_name': 'tabBudget', 'table_rows': 1},
  72. {'database_name': 'production',
  73. 'table_name': 'tabBudget Account',
  74. 'table_rows': 2},
  75. {'database_name': 'production', 'table_name': 'tabCampaign', 'table_rows': 2},
  76. {'database_name': 'production',
  77. 'table_name': 'tabCash Flow Mapper',
  78. 'table_rows': 3},
  79. {'database_name': 'production',
  80. 'table_name': 'tabChat Message',
  81. 'table_rows': 2},
  82. {'database_name': 'production',
  83. 'table_name': 'tabChat Profile',
  84. 'table_rows': 54},
  85. {'database_name': 'production',
  86. 'table_name': 'tabChat Room',
  87. 'table_rows': 3},
  88. {'database_name': 'production',
  89. 'table_name': 'tabChat Room User',
  90. 'table_rows': 3},
  91. {'database_name': 'production',
  92. 'table_name': 'tabComment',
  93. 'table_rows': 62353},
  94. {'database_name': 'production',
  95. 'table_name': 'tabCommunication',
  96. 'table_rows': 21},
  97. {'database_name': 'production',
  98. 'table_name': 'tabCommunication Link',
  99. 'table_rows': 5},
  100. {'database_name': 'production', 'table_name': 'tabCompany', 'table_rows': 3},
  101. {'database_name': 'production',
  102. 'table_name': 'tabContact',
  103. 'table_rows': 14322},
  104. {'database_name': 'production',
  105. 'table_name': 'tabContact Email',
  106. 'table_rows': 2249},
  107. {'database_name': 'production',
  108. 'table_name': 'tabContact Phone',
  109. 'table_rows': 13872},
  110. {'database_name': 'production',
  111. 'table_name': 'tabContainer',
  112. 'table_rows': 3},
  113. {'database_name': 'production',
  114. 'table_name': 'tabCost Center',
  115. 'table_rows': 63},
  116. {'database_name': 'production',
  117. 'table_name': 'tabCountry',
  118. 'table_rows': 250},
  119. {'database_name': 'production',
  120. 'table_name': 'tabCurrency',
  121. 'table_rows': 149},
  122. {'database_name': 'production',
  123. 'table_name': 'tabCurrency Exchange',
  124. 'table_rows': 7},
  125. {'database_name': 'production',
  126. 'table_name': 'tabCustom DocPerm',
  127. 'table_rows': 275},
  128. {'database_name': 'production',
  129. 'table_name': 'tabCustom Field',
  130. 'table_rows': 162},
  131. {'database_name': 'production',
  132. 'table_name': 'tabCustom Script',
  133. 'table_rows': 1},
  134. {'database_name': 'production',
  135. 'table_name': 'tabCustomer',
  136. 'table_rows': 29080},
  137. {'database_name': 'production',
  138. 'table_name': 'tabCustomer Credit Limit',
  139. 'table_rows': 12},
  140. {'database_name': 'production',
  141. 'table_name': 'tabCustomer Group',
  142. 'table_rows': 18},
  143. {'database_name': 'production',
  144. 'table_name': 'tabDashboard',
  145. 'table_rows': 1},
  146. {'database_name': 'production',
  147. 'table_name': 'tabDashboard Chart',
  148. 'table_rows': 3},
  149. {'database_name': 'production',
  150. 'table_name': 'tabDashboard Chart Link',
  151. 'table_rows': 2},
  152. {'database_name': 'production',
  153. 'table_name': 'tabData Import',
  154. 'table_rows': 5},
  155. {'database_name': 'production',
  156. 'table_name': 'tabData Import Legacy',
  157. 'table_rows': 6},
  158. {'database_name': 'production',
  159. 'table_name': 'tabData Migration Mapping',
  160. 'table_rows': 5},
  161. {'database_name': 'production',
  162. 'table_name': 'tabData Migration Mapping Detail',
  163. 'table_rows': 21},
  164. {'database_name': 'production',
  165. 'table_name': 'tabData Migration Plan',
  166. 'table_rows': 2},
  167. {'database_name': 'production',
  168. 'table_name': 'tabData Migration Plan Mapping',
  169. 'table_rows': 3},
  170. {'database_name': 'production',
  171. 'table_name': 'tabDefaultValue',
  172. 'table_rows': 67},
  173. {'database_name': 'production',
  174. 'table_name': 'tabDeleted Document',
  175. 'table_rows': 11863},
  176. {'database_name': 'production',
  177. 'table_name': 'tabDelivery Driver',
  178. 'table_rows': 10},
  179. {'database_name': 'production',
  180. 'table_name': 'tabDelivery Note',
  181. 'table_rows': 607},
  182. {'database_name': 'production',
  183. 'table_name': 'tabDelivery Note Item',
  184. 'table_rows': 1026},
  185. {'database_name': 'production',
  186. 'table_name': 'tabDelivery Return Reason',
  187. 'table_rows': 2},
  188. {'database_name': 'production',
  189. 'table_name': 'tabDelivery Sector',
  190. 'table_rows': 123},
  191. {'database_name': 'production',
  192. 'table_name': 'tabDelivery Stop',
  193. 'table_rows': 609},
  194. {'database_name': 'production',
  195. 'table_name': 'tabDelivery Trip',
  196. 'table_rows': 533},
  197. {'database_name': 'production',
  198. 'table_name': 'tabDepartment',
  199. 'table_rows': 40},
  200. {'database_name': 'production',
  201. 'table_name': 'tabDepreciation Schedule',
  202. 'table_rows': 180},
  203. {'database_name': 'production',
  204. 'table_name': 'tabDesignation',
  205. 'table_rows': 77},
  206. {'database_name': 'production',
  207. 'table_name': 'tabDocField',
  208. 'table_rows': 11507},
  209. {'database_name': 'production',
  210. 'table_name': 'tabDocPerm',
  211. 'table_rows': 1157},
  212. {'database_name': 'production',
  213. 'table_name': 'tabDocShare',
  214. 'table_rows': 185},
  215. {'database_name': 'production',
  216. 'table_name': 'tabDocType',
  217. 'table_rows': 909},
  218. {'database_name': 'production',
  219. 'table_name': 'tabDocument Follow',
  220. 'table_rows': 4883},
  221. {'database_name': 'production', 'table_name': 'tabDomain', 'table_rows': 7},
  222. {'database_name': 'production', 'table_name': 'tabDriver', 'table_rows': 10},
  223. {'database_name': 'production',
  224. 'table_name': 'tabDynamic Link',
  225. 'table_rows': 27815},
  226. {'database_name': 'production',
  227. 'table_name': 'tabEmail Account',
  228. 'table_rows': 3},
  229. {'database_name': 'production',
  230. 'table_name': 'tabEmail Domain',
  231. 'table_rows': 2},
  232. {'database_name': 'production',
  233. 'table_name': 'tabEmail Queue',
  234. 'table_rows': 18217},
  235. {'database_name': 'production',
  236. 'table_name': 'tabEmail Queue Recipient',
  237. 'table_rows': 30360},
  238. {'database_name': 'production',
  239. 'table_name': 'tabEmail Unsubscribe',
  240. 'table_rows': 2},
  241. {'database_name': 'production',
  242. 'table_name': 'tabEmployee',
  243. 'table_rows': 287},
  244. {'database_name': 'production',
  245. 'table_name': 'tabEmployee Checkin',
  246. 'table_rows': 181},
  247. {'database_name': 'production',
  248. 'table_name': 'tabEmployee Education',
  249. 'table_rows': 313},
  250. {'database_name': 'production',
  251. 'table_name': 'tabEmployee External Work History',
  252. 'table_rows': 91},
  253. {'database_name': 'production',
  254. 'table_name': 'tabEmployee Grade',
  255. 'table_rows': 2},
  256. {'database_name': 'production',
  257. 'table_name': 'tabEmployee Health Insurance',
  258. 'table_rows': 8},
  259. {'database_name': 'production',
  260. 'table_name': 'tabEmployee Internal Work History',
  261. 'table_rows': 496},
  262. {'database_name': 'production',
  263. 'table_name': 'tabEmployee Property History',
  264. 'table_rows': 7},
  265. {'database_name': 'production',
  266. 'table_name': 'tabEmployee Transfer',
  267. 'table_rows': 7},
  268. {'database_name': 'production',
  269. 'table_name': 'tabEmployee Warehouse',
  270. 'table_rows': 64},
  271. {'database_name': 'production',
  272. 'table_name': 'tabEmployment Type',
  273. 'table_rows': 11},
  274. {'database_name': 'production',
  275. 'table_name': 'tabEnergy Point Log',
  276. 'table_rows': 24824},
  277. {'database_name': 'production',
  278. 'table_name': 'tabEnergy Point Rule',
  279. 'table_rows': 8},
  280. {'database_name': 'production',
  281. 'table_name': 'tabError Log',
  282. 'table_rows': 12742},
  283. {'database_name': 'production',
  284. 'table_name': 'tabError Snapshot',
  285. 'table_rows': 74},
  286. {'database_name': 'production', 'table_name': 'tabEvent', 'table_rows': 5},
  287. {'database_name': 'production',
  288. 'table_name': 'tabEvent Participants',
  289. 'table_rows': 5},
  290. {'database_name': 'production', 'table_name': 'tabFile', 'table_rows': 3295},
  291. {'database_name': 'production',
  292. 'table_name': 'tabFinance Book',
  293. 'table_rows': 2},
  294. {'database_name': 'production',
  295. 'table_name': 'tabFiscal Year',
  296. 'table_rows': 5},
  297. {'database_name': 'production',
  298. 'table_name': 'tabFiscal Year Company',
  299. 'table_rows': 2},
  300. {'database_name': 'production', 'table_name': 'tabGender', 'table_rows': 10},
  301. {'database_name': 'production',
  302. 'table_name': 'tabGeneric',
  303. 'table_rows': 890},
  304. {'database_name': 'production',
  305. 'table_name': 'tabGL Entry',
  306. 'table_rows': 7322067},
  307. {'database_name': 'production',
  308. 'table_name': 'tabGlobal Search DocType',
  309. 'table_rows': 61},
  310. {'database_name': 'production',
  311. 'table_name': 'tabHas Role',
  312. 'table_rows': 2590},
  313. {'database_name': 'production', 'table_name': 'tabHoliday', 'table_rows': 37},
  314. {'database_name': 'production',
  315. 'table_name': 'tabHoliday List',
  316. 'table_rows': 6},
  317. {'database_name': 'production',
  318. 'table_name': 'tabIncome Tax Slab',
  319. 'table_rows': 1},
  320. {'database_name': 'production',
  321. 'table_name': 'tabIncome Tax Slab Other Charges',
  322. 'table_rows': 2},
  323. {'database_name': 'production',
  324. 'table_name': 'tabInstalled Application',
  325. 'table_rows': 11},
  326. {'database_name': 'production', 'table_name': 'tabIssue', 'table_rows': 431},
  327. {'database_name': 'production',
  328. 'table_name': 'tabIssue Priority',
  329. 'table_rows': 6},
  330. {'database_name': 'production',
  331. 'table_name': 'tabIssue Type',
  332. 'table_rows': 130},
  333. {'database_name': 'production', 'table_name': 'tabItem', 'table_rows': 2314},
  334. {'database_name': 'production',
  335. 'table_name': 'tabItem Barcode',
  336. 'table_rows': 12},
  337. {'database_name': 'production',
  338. 'table_name': 'tabItem Customer Detail',
  339. 'table_rows': 2},
  340. {'database_name': 'production',
  341. 'table_name': 'tabItem Default',
  342. 'table_rows': 772},
  343. {'database_name': 'production',
  344. 'table_name': 'tabItem Group',
  345. 'table_rows': 444},
  346. {'database_name': 'production',
  347. 'table_name': 'tabItem Price',
  348. 'table_rows': 1658},
  349. {'database_name': 'production',
  350. 'table_name': 'tabItem Quality Inspection Parameter',
  351. 'table_rows': 3},
  352. {'database_name': 'production',
  353. 'table_name': 'tabItem Supplier',
  354. 'table_rows': 141},
  355. {'database_name': 'production',
  356. 'table_name': 'tabItem Tax Template',
  357. 'table_rows': 2},
  358. {'database_name': 'production',
  359. 'table_name': 'tabItem Tax Template Detail',
  360. 'table_rows': 3},
  361. {'database_name': 'production',
  362. 'table_name': 'tabJob Applicant',
  363. 'table_rows': 217},
  364. {'database_name': 'production',
  365. 'table_name': 'tabJob Applicant Source',
  366. 'table_rows': 8},
  367. {'database_name': 'production',
  368. 'table_name': 'tabJob Opening',
  369. 'table_rows': 16},
  370. {'database_name': 'production',
  371. 'table_name': 'tabJournal Entry',
  372. 'table_rows': 1400},
  373. {'database_name': 'production',
  374. 'table_name': 'tabJournal Entry Account',
  375. 'table_rows': 4232},
  376. {'database_name': 'production',
  377. 'table_name': 'tabKanban Board',
  378. 'table_rows': 2},
  379. {'database_name': 'production',
  380. 'table_name': 'tabKanban Board Column',
  381. 'table_rows': 14},
  382. {'database_name': 'production',
  383. 'table_name': 'tabLanded Cost Item',
  384. 'table_rows': 516},
  385. {'database_name': 'production',
  386. 'table_name': 'tabLanded Cost Purchase Receipt',
  387. 'table_rows': 57},
  388. {'database_name': 'production',
  389. 'table_name': 'tabLanded Cost Taxes and Charges',
  390. 'table_rows': 275},
  391. {'database_name': 'production',
  392. 'table_name': 'tabLanded Cost Voucher',
  393. 'table_rows': 31},
  394. {'database_name': 'production',
  395. 'table_name': 'tabLanguage',
  396. 'table_rows': 80},
  397. {'database_name': 'production', 'table_name': 'tabLead', 'table_rows': 6},
  398. {'database_name': 'production',
  399. 'table_name': 'tabLead Source',
  400. 'table_rows': 5},
  401. {'database_name': 'production',
  402. 'table_name': 'tabLeave Allocation',
  403. 'table_rows': 260},
  404. {'database_name': 'production',
  405. 'table_name': 'tabLeave Application',
  406. 'table_rows': 94},
  407. {'database_name': 'production',
  408. 'table_name': 'tabLeave Ledger Entry',
  409. 'table_rows': 531},
  410. {'database_name': 'production',
  411. 'table_name': 'tabLeave Policy Detail',
  412. 'table_rows': 2},
  413. {'database_name': 'production',
  414. 'table_name': 'tabLeave Type',
  415. 'table_rows': 27},
  416. {'database_name': 'production',
  417. 'table_name': 'tabLetter Head',
  418. 'table_rows': 1},
  419. {'database_name': 'production',
  420. 'table_name': 'tabLoading Conversion Detail',
  421. 'table_rows': 134},
  422. {'database_name': 'production',
  423. 'table_name': 'tabLocation',
  424. 'table_rows': 14},
  425. {'database_name': 'production',
  426. 'table_name': 'tabMardom Endpoint',
  427. 'table_rows': 2},
  428. {'database_name': 'production',
  429. 'table_name': 'tabMarket Segment',
  430. 'table_rows': 3},
  431. {'database_name': 'production',
  432. 'table_name': 'tabMaterial Request',
  433. 'table_rows': 4953},
  434. {'database_name': 'production',
  435. 'table_name': 'tabMaterial Request Item',
  436. 'table_rows': 28013},
  437. {'database_name': 'production',
  438. 'table_name': 'tabMaterial Request Plan Item',
  439. 'table_rows': 8},
  440. {'database_name': 'production',
  441. 'table_name': 'tabMobile Assignement',
  442. 'table_rows': 3},
  443. {'database_name': 'production',
  444. 'table_name': 'tabMobile Assignment',
  445. 'table_rows': 10},
  446. {'database_name': 'production',
  447. 'table_name': 'tabMode of Payment',
  448. 'table_rows': 18},
  449. {'database_name': 'production',
  450. 'table_name': 'tabMode of Payment Account',
  451. 'table_rows': 21},
  452. {'database_name': 'production',
  453. 'table_name': 'tabModule Def',
  454. 'table_rows': 47},
  455. {'database_name': 'production',
  456. 'table_name': 'tabMonthly Distribution',
  457. 'table_rows': 2},
  458. {'database_name': 'production',
  459. 'table_name': 'tabMonthly Distribution Percentage',
  460. 'table_rows': 24},
  461. {'database_name': 'production',
  462. 'table_name': 'tabNCF Chart',
  463. 'table_rows': 5},
  464. {'database_name': 'production',
  465. 'table_name': 'tabNCF Manager Log',
  466. 'table_rows': 485},
  467. {'database_name': 'production',
  468. 'table_name': 'tabNotification',
  469. 'table_rows': 5},
  470. {'database_name': 'production',
  471. 'table_name': 'tabNotification Log',
  472. 'table_rows': 25761},
  473. {'database_name': 'production',
  474. 'table_name': 'tabNotification Recipient',
  475. 'table_rows': 6},
  476. {'database_name': 'production',
  477. 'table_name': 'tabNotification Settings',
  478. 'table_rows': 50},
  479. {'database_name': 'production',
  480. 'table_name': 'tabOAuth Authorization Code',
  481. 'table_rows': 7},
  482. {'database_name': 'production',
  483. 'table_name': 'tabOAuth Bearer Token',
  484. 'table_rows': 73},
  485. {'database_name': 'production',
  486. 'table_name': 'tabOAuth Client',
  487. 'table_rows': 1},
  488. {'database_name': 'production',
  489. 'table_name': 'tabOpening Invoice Creation Tool Item',
  490. 'table_rows': 2},
  491. {'database_name': 'production',
  492. 'table_name': 'tabOpportunity',
  493. 'table_rows': 2},
  494. {'database_name': 'production',
  495. 'table_name': 'tabPacked Item',
  496. 'table_rows': 6730894},
  497. {'database_name': 'production', 'table_name': 'tabPage', 'table_rows': 21},
  498. {'database_name': 'production',
  499. 'table_name': 'tabParty Account',
  500. 'table_rows': 69},
  501. {'database_name': 'production',
  502. 'table_name': 'tabParty Type',
  503. 'table_rows': 6},
  504. {'database_name': 'production',
  505. 'table_name': 'tabPatch Log',
  506. 'table_rows': 939},
  507. {'database_name': 'production',
  508. 'table_name': 'tabPayment Entry',
  509. 'table_rows': 59},
  510. {'database_name': 'production',
  511. 'table_name': 'tabPayment Entry Reference',
  512. 'table_rows': 2191},
  513. {'database_name': 'production',
  514. 'table_name': 'tabPayment Schedule',
  515. 'table_rows': 108763},
  516. {'database_name': 'production',
  517. 'table_name': 'tabPayment Term',
  518. 'table_rows': 19},
  519. {'database_name': 'production',
  520. 'table_name': 'tabPayment Terms Template',
  521. 'table_rows': 20},
  522. {'database_name': 'production',
  523. 'table_name': 'tabPayment Terms Template Detail',
  524. 'table_rows': 21},
  525. {'database_name': 'production',
  526. 'table_name': 'tabPortal Menu Item',
  527. 'table_rows': 22},
  528. {'database_name': 'production',
  529. 'table_name': 'tabPrepared Report',
  530. 'table_rows': 1470},
  531. {'database_name': 'production',
  532. 'table_name': 'tabPrice List',
  533. 'table_rows': 18},
  534. {'database_name': 'production',
  535. 'table_name': 'tabPrice List Country',
  536. 'table_rows': 9},
  537. {'database_name': 'production',
  538. 'table_name': 'tabPricing Rule',
  539. 'table_rows': 27},
  540. {'database_name': 'production',
  541. 'table_name': 'tabPricing Rule Item Group',
  542. 'table_rows': 38},
  543. {'database_name': 'production',
  544. 'table_name': 'tabPrint Format',
  545. 'table_rows': 49},
  546. {'database_name': 'production',
  547. 'table_name': 'tabPrint Style',
  548. 'table_rows': 3},
  549. {'database_name': 'production',
  550. 'table_name': 'tabProduct Bundle',
  551. 'table_rows': 510},
  552. {'database_name': 'production',
  553. 'table_name': 'tabProduct Bundle Item',
  554. 'table_rows': 1793},
  555. {'database_name': 'production',
  556. 'table_name': 'tabProduction Plan',
  557. 'table_rows': 537},
  558. {'database_name': 'production',
  559. 'table_name': 'tabProduction Plan Item',
  560. 'table_rows': 2600},
  561. {'database_name': 'production',
  562. 'table_name': 'tabProduction Plan Material Request',
  563. 'table_rows': 557},
  564. {'database_name': 'production',
  565. 'table_name': 'tabProduction Plan Sales Order',
  566. 'table_rows': 5},
  567. {'database_name': 'production', 'table_name': 'tabProject', 'table_rows': 12},
  568. {'database_name': 'production',
  569. 'table_name': 'tabProject Template',
  570. 'table_rows': 3},
  571. {'database_name': 'production',
  572. 'table_name': 'tabProject Template Task',
  573. 'table_rows': 4},
  574. {'database_name': 'production',
  575. 'table_name': 'tabProject Type',
  576. 'table_rows': 3},
  577. {'database_name': 'production',
  578. 'table_name': 'tabProperty Setter',
  579. 'table_rows': 154},
  580. {'database_name': 'production',
  581. 'table_name': 'tabPurchase Estimation',
  582. 'table_rows': 10},
  583. {'database_name': 'production',
  584. 'table_name': 'tabPurchase Estimation Item',
  585. 'table_rows': 162},
  586. {'database_name': 'production',
  587. 'table_name': 'tabPurchase Estimation Template',
  588. 'table_rows': 8},
  589. {'database_name': 'production',
  590. 'table_name': 'tabPurchase Estimation Template Item',
  591. 'table_rows': 196},
  592. {'database_name': 'production',
  593. 'table_name': 'tabPurchase Invoice',
  594. 'table_rows': 1747},
  595. {'database_name': 'production',
  596. 'table_name': 'tabPurchase Invoice Item',
  597. 'table_rows': 2773},
  598. {'database_name': 'production',
  599. 'table_name': 'tabPurchase Order',
  600. 'table_rows': 419},
  601. {'database_name': 'production',
  602. 'table_name': 'tabPurchase Order Item',
  603. 'table_rows': 1643},
  604. {'database_name': 'production',
  605. 'table_name': 'tabPurchase Receipt',
  606. 'table_rows': 441},
  607. {'database_name': 'production',
  608. 'table_name': 'tabPurchase Receipt Item',
  609. 'table_rows': 1382},
  610. {'database_name': 'production',
  611. 'table_name': 'tabPurchase Taxes and Charges',
  612. 'table_rows': 2099},
  613. {'database_name': 'production',
  614. 'table_name': 'tabPurchase Taxes and Charges Template',
  615. 'table_rows': 8},
  616. {'database_name': 'production',
  617. 'table_name': 'tabQuotation',
  618. 'table_rows': 46},
  619. {'database_name': 'production',
  620. 'table_name': 'tabQuotation Item',
  621. 'table_rows': 147},
  622. {'database_name': 'production', 'table_name': 'tabReport', 'table_rows': 191},
  623. {'database_name': 'production',
  624. 'table_name': 'tabRetirement Insurer',
  625. 'table_rows': 4},
  626. {'database_name': 'production', 'table_name': 'tabRole', 'table_rows': 74},
  627. {'database_name': 'production',
  628. 'table_name': 'tabRole Profile',
  629. 'table_rows': 14},
  630. {'database_name': 'production',
  631. 'table_name': 'tabRoute History',
  632. 'table_rows': 204868},
  633. {'database_name': 'production',
  634. 'table_name': 'tabSalary Component',
  635. 'table_rows': 8},
  636. {'database_name': 'production',
  637. 'table_name': 'tabSalary Detail',
  638. 'table_rows': 208},
  639. {'database_name': 'production',
  640. 'table_name': 'tabSalary Slip',
  641. 'table_rows': 2},
  642. {'database_name': 'production',
  643. 'table_name': 'tabSales Invoice',
  644. 'table_rows': 1232968},
  645. {'database_name': 'production',
  646. 'table_name': 'tabSales Invoice Item',
  647. 'table_rows': 3060465},
  648. {'database_name': 'production',
  649. 'table_name': 'tabSales Invoice Payment',
  650. 'table_rows': 1471515},
  651. {'database_name': 'production',
  652. 'table_name': 'tabSales Order',
  653. 'table_rows': 15465},
  654. {'database_name': 'production',
  655. 'table_name': 'tabSales Order Item',
  656. 'table_rows': 28371},
  657. {'database_name': 'production',
  658. 'table_name': 'tabSales Partner',
  659. 'table_rows': 1},
  660. {'database_name': 'production',
  661. 'table_name': 'tabSales Scrap Entry',
  662. 'table_rows': 609},
  663. {'database_name': 'production',
  664. 'table_name': 'tabSales Scrap Entry Item',
  665. 'table_rows': 1288},
  666. {'database_name': 'production',
  667. 'table_name': 'tabSales Scrap Entry Reason',
  668. 'table_rows': 13},
  669. {'database_name': 'production',
  670. 'table_name': 'tabSales Taxes and Charges',
  671. 'table_rows': 3551440},
  672. {'database_name': 'production',
  673. 'table_name': 'tabSales Taxes and Charges Template',
  674. 'table_rows': 6},
  675. {'database_name': 'production',
  676. 'table_name': 'tabSalutation',
  677. 'table_rows': 9},
  678. {'database_name': 'production', 'table_name': 'tabSeries', 'table_rows': 208},
  679. {'database_name': 'production',
  680. 'table_name': 'tabSessions',
  681. 'table_rows': 29},
  682. {'database_name': 'production',
  683. 'table_name': 'tabShareholder',
  684. 'table_rows': 2},
  685. {'database_name': 'production',
  686. 'table_name': 'tabShift Type',
  687. 'table_rows': 4},
  688. {'database_name': 'production',
  689. 'table_name': 'tabShipping Rule',
  690. 'table_rows': 2},
  691. {'database_name': 'production',
  692. 'table_name': 'tabSingles',
  693. 'table_rows': 1538},
  694. {'database_name': 'production', 'table_name': 'tabSkill', 'table_rows': 2},
  695. {'database_name': 'production',
  696. 'table_name': 'tabSocial Login Key',
  697. 'table_rows': 1},
  698. {'database_name': 'production',
  699. 'table_name': 'tabStock Availability',
  700. 'table_rows': 10},
  701. {'database_name': 'production',
  702. 'table_name': 'tabStock Availability Item',
  703. 'table_rows': 1093},
  704. {'database_name': 'production',
  705. 'table_name': 'tabStock Entry',
  706. 'table_rows': 12897},
  707. {'database_name': 'production',
  708. 'table_name': 'tabStock Entry Detail',
  709. 'table_rows': 70495},
  710. {'database_name': 'production',
  711. 'table_name': 'tabStock Entry Type',
  712. 'table_rows': 9},
  713. {'database_name': 'production',
  714. 'table_name': 'tabStock Ledger Entry',
  715. 'table_rows': 251159},
  716. {'database_name': 'production',
  717. 'table_name': 'tabStock Reconciliation',
  718. 'table_rows': 481},
  719. {'database_name': 'production',
  720. 'table_name': 'tabStock Reconciliation Item',
  721. 'table_rows': 4260},
  722. {'database_name': 'production',
  723. 'table_name': 'tabStock Take',
  724. 'table_rows': 4441},
  725. {'database_name': 'production',
  726. 'table_name': 'tabStock Take Difference',
  727. 'table_rows': 250605},
  728. {'database_name': 'production',
  729. 'table_name': 'tabStock Take Item',
  730. 'table_rows': 289349},
  731. {'database_name': 'production',
  732. 'table_name': 'tabStock Take Purpose',
  733. 'table_rows': 6},
  734. {'database_name': 'production',
  735. 'table_name': 'tabStock Take Purpose Item',
  736. 'table_rows': 293},
  737. {'database_name': 'production',
  738. 'table_name': 'tabStock Take Template',
  739. 'table_rows': 6},
  740. {'database_name': 'production',
  741. 'table_name': 'tabStock Take Template Item',
  742. 'table_rows': 258},
  743. {'database_name': 'production',
  744. 'table_name': 'tabStock Take Type',
  745. 'table_rows': 3},
  746. {'database_name': 'production',
  747. 'table_name': 'tabStock Take UOM',
  748. 'table_rows': 1497},
  749. {'database_name': 'production',
  750. 'table_name': 'tabSuccess Action',
  751. 'table_rows': 6},
  752. {'database_name': 'production',
  753. 'table_name': 'tabSupplier',
  754. 'table_rows': 342},
  755. {'database_name': 'production',
  756. 'table_name': 'tabSupplier Group',
  757. 'table_rows': 15},
  758. {'database_name': 'production',
  759. 'table_name': 'tabSupply Ledger Entry',
  760. 'table_rows': 6753742},
  761. {'database_name': 'production', 'table_name': 'tabTag', 'table_rows': 2},
  762. {'database_name': 'production', 'table_name': 'tabTag Link', 'table_rows': 2},
  763. {'database_name': 'production', 'table_name': 'tabTask', 'table_rows': 136},
  764. {'database_name': 'production',
  765. 'table_name': 'tabTask Depends On',
  766. 'table_rows': 81},
  767. {'database_name': 'production',
  768. 'table_name': 'tabTask Type',
  769. 'table_rows': 2},
  770. {'database_name': 'production',
  771. 'table_name': 'tabTax Category',
  772. 'table_rows': 2},
  773. {'database_name': 'production', 'table_name': 'tabTax Rule', 'table_rows': 2},
  774. {'database_name': 'production',
  775. 'table_name': 'tabTaxable Salary Slab',
  776. 'table_rows': 4},
  777. {'database_name': 'production',
  778. 'table_name': 'tabTerms and Conditions',
  779. 'table_rows': 6},
  780. {'database_name': 'production',
  781. 'table_name': 'tabTerritory',
  782. 'table_rows': 18},
  783. {'database_name': 'production',
  784. 'table_name': 'tabTimesheet Detail',
  785. 'table_rows': 402},
  786. {'database_name': 'production', 'table_name': 'tabToDo', 'table_rows': 632},
  787. {'database_name': 'production',
  788. 'table_name': 'tabToDo Context',
  789. 'table_rows': 5},
  790. {'database_name': 'production',
  791. 'table_name': 'tabTranslation',
  792. 'table_rows': 22},
  793. {'database_name': 'production', 'table_name': 'tabUOM', 'table_rows': 684},
  794. {'database_name': 'production',
  795. 'table_name': 'tabUOM Category',
  796. 'table_rows': 17},
  797. {'database_name': 'production',
  798. 'table_name': 'tabUOM Conversion Detail',
  799. 'table_rows': 3786},
  800. {'database_name': 'production',
  801. 'table_name': 'tabUOM Conversion Factor',
  802. 'table_rows': 235},
  803. {'database_name': 'production', 'table_name': 'tabUser', 'table_rows': 328},
  804. {'database_name': 'production',
  805. 'table_name': 'tabUser Permission',
  806. 'table_rows': 325},
  807. {'database_name': 'production',
  808. 'table_name': 'tabUser Social Login',
  809. 'table_rows': 211},
  810. {'database_name': 'production', 'table_name': 'tabVehicle', 'table_rows': 6},
  811. {'database_name': 'production',
  812. 'table_name': 'tabVersion',
  813. 'table_rows': 9461993},
  814. {'database_name': 'production', 'table_name': 'tabView Log', 'table_rows': 4},
  815. {'database_name': 'production',
  816. 'table_name': 'tabVolume Conversion Detail',
  817. 'table_rows': 154},
  818. {'database_name': 'production',
  819. 'table_name': 'tabWarehouse',
  820. 'table_rows': 56},
  821. {'database_name': 'production',
  822. 'table_name': 'tabWarehouse Group',
  823. 'table_rows': 8},
  824. {'database_name': 'production',
  825. 'table_name': 'tabWarehouse Group Item',
  826. 'table_rows': 36},
  827. {'database_name': 'production',
  828. 'table_name': 'tabWarehouse Type',
  829. 'table_rows': 3},
  830. {'database_name': 'production',
  831. 'table_name': 'tabWeb Form',
  832. 'table_rows': 15},
  833. {'database_name': 'production',
  834. 'table_name': 'tabWeb Form Field',
  835. 'table_rows': 112},
  836. {'database_name': 'production',
  837. 'table_name': 'tabWebsite Callback Configuration Endpoints',
  838. 'table_rows': 2},
  839. {'database_name': 'production',
  840. 'table_name': 'tabWebsite Theme',
  841. 'table_rows': 1},
  842. {'database_name': 'production',
  843. 'table_name': 'tabWeight Conversion Detail',
  844. 'table_rows': 154},
  845. {'database_name': 'production',
  846. 'table_name': 'tabWoocommerce Order',
  847. 'table_rows': 2341},
  848. {'database_name': 'production',
  849. 'table_name': 'tabWoocommerce Order Item',
  850. 'table_rows': 3080},
  851. {'database_name': 'production',
  852. 'table_name': 'tabWork Order',
  853. 'table_rows': 2599},
  854. {'database_name': 'production',
  855. 'table_name': 'tabWork Order Item',
  856. 'table_rows': 12964},
  857. {'database_name': 'production',
  858. 'table_name': 'tabWorkflow Action Master',
  859. 'table_rows': 3},
  860. {'database_name': 'production',
  861. 'table_name': 'tabWorkflow State',
  862. 'table_rows': 3},
  863. {'database_name': 'production',
  864. 'table_name': 'tabYPOS Account',
  865. 'table_rows': 90},
  866. {'database_name': 'production',
  867. 'table_name': 'tabYPOS Aggregator Customer',
  868. 'table_rows': 4},
  869. {'database_name': 'production',
  870. 'table_name': 'tabYPOS Canal',
  871. 'table_rows': 9},
  872. {'database_name': 'production',
  873. 'table_name': 'tabYPOS Connector',
  874. 'table_rows': 11},
  875. {'database_name': 'production',
  876. 'table_name': 'tabYPOS Doctype Mapper',
  877. 'table_rows': 1},
  878. {'database_name': 'production',
  879. 'table_name': 'tabYPOS Doctype Mapper Child',
  880. 'table_rows': 7},
  881. {'database_name': 'production',
  882. 'table_name': 'tabYPOS Invoice Import',
  883. 'table_rows': 771626},
  884. {'database_name': 'production',
  885. 'table_name': 'tabYPOS Item Sync',
  886. 'table_rows': 10029},
  887. {'database_name': 'production',
  888. 'table_name': 'tabYPOS Price Mapper Child',
  889. 'table_rows': 3},
  890. {'database_name': 'production',
  891. 'table_name': 'tabYPOS Sales Channel',
  892. 'table_rows': 173},
  893. {'database_name': 'production',
  894. 'table_name': 'tabYPOS Sales Channel Sync',
  895. 'table_rows': 760},
  896. {'database_name': 'production',
  897. 'table_name': 'tempCost Center',
  898. 'table_rows': 2077},
  899. {'database_name': 'production', 'table_name': 'tmpacct', 'table_rows': 1410},
  900. {'database_name': 'production', 'table_name': '__Auth', 'table_rows': 108},
  901. {'database_name': 'production',
  902. 'table_name': '__global_search',
  903. 'table_rows': 2904073},
  904. {'database_name': 'production',
  905. 'table_name': '__UserSettings',
  906. 'table_rows': 3023}]
  907. tables_production = {table['table_name']: table for table in res_production}
  908.  
  909. # staging tables
  910. query = """
  911. select table_schema as database_name,
  912.    table_name,
  913.    table_rows
  914. from information_schema.tables
  915. where table_type = 'BASE TABLE'
  916.    and table_schema not in('information_schema', 'sys',
  917.                            'performance_schema', 'mysql')
  918.    and table_schema = 'staging'
  919. order by table_schema,
  920.        table_name;
  921. """
  922. res_staging = frappe.db.sql(query, as_dict=True)
  923. tables_staging = {table['table_name']: table for table in res_staging}
  924. tables_diff = dict()
  925. for name, table in tables_production.items():
  926.     table_staging = tables_staging.get(name, dict())
  927.     tables_diff[name] = {
  928.         "table_production": table,
  929.         "table_staging": table_staging,
  930.         "table_rows_diff": table_staging.get("table_rows", 0) - table.get("table_rows", 0)
  931.     }
  932.  
  933. tables_failed = {name: table for name, table in tables_diff.items() if abs(table.get('table_rows_diff')) >= table['table_production']['table_rows']}
Add Comment
Please, Sign In to add comment