This function will compare the two databases.
(params)
| 480 | @socketio.on('compare_database', namespace=SOCKETIO_NAMESPACE) |
| 481 | @socket_login_required |
| 482 | def compare_database(params): |
| 483 | """ |
| 484 | This function will compare the two databases. |
| 485 | """ |
| 486 | # Check the pre validation before compare |
| 487 | SchemaDiffRegistry.set_schema_diff_compare_mode('Database Objects') |
| 488 | status, error_msg, diff_model_obj, session_obj = \ |
| 489 | compare_pre_validation(params['trans_id'], params['source_sid'], |
| 490 | params['target_sid']) |
| 491 | if not status: |
| 492 | socketio.emit('compare_database_failed', |
| 493 | error_msg.json if isinstance( |
| 494 | error_msg, Response) else error_msg, |
| 495 | namespace=SOCKETIO_NAMESPACE, to=request.sid) |
| 496 | return error_msg |
| 497 | |
| 498 | comparison_result = [] |
| 499 | |
| 500 | socketio.emit('compare_status', {'diff_percentage': 0, |
| 501 | 'compare_msg': COMPARE_MSG}, namespace=SOCKETIO_NAMESPACE, |
| 502 | to=request.sid) |
| 503 | update_session_diff_transaction(params['trans_id'], session_obj, |
| 504 | diff_model_obj) |
| 505 | |
| 506 | try: |
| 507 | ignore_owner = bool(params['ignore_owner']) |
| 508 | ignore_whitespaces = bool(params['ignore_whitespaces']) |
| 509 | ignore_tablespace = bool(params['ignore_tablespace']) |
| 510 | ignore_grants = bool(params['ignore_grants']) |
| 511 | |
| 512 | # Fetch all the schemas of source and target database |
| 513 | # Compare them and get the status. |
| 514 | schema_result = \ |
| 515 | fetch_compare_schemas(params['source_sid'], params['source_did'], |
| 516 | params['target_sid'], params['target_did']) |
| 517 | |
| 518 | if schema_result is None: |
| 519 | socketio.emit( |
| 520 | 'compare_database_failed', |
| 521 | gettext( |
| 522 | "Failed to fetch schemas from the" |
| 523 | " server."), |
| 524 | namespace=SOCKETIO_NAMESPACE, to=request.sid) |
| 525 | return |
| 526 | |
| 527 | total_schema = len(schema_result['source_only']) + len( |
| 528 | schema_result['target_only']) + len( |
| 529 | schema_result['in_both_database']) |
| 530 | |
| 531 | node_percent = 0 |
| 532 | if total_schema > 0: |
| 533 | node_percent = round(100 / (total_schema * len( |
| 534 | SchemaDiffRegistry.get_registered_nodes())), 2) |
| 535 | total_percent = 0 |
| 536 | |
| 537 | # Compare Database objects |
| 538 | comparison_schema_result, total_percent = \ |
| 539 | compare_database_objects( |
nothing calls this directly
no test coverage detected