

def migrate(cr, version):
    cr.execute('ALTER TABLE carepoint_medical_prescription_order_line '
               'RENAME TO carepoint_rx_ord_ln')

    cr.execute('ALTER TABLE carepoint_carepoint_organization '
               'RENAME TO carepoint_org_bind')


import logging

_logger = logging.getLogger(__name__)


def migrate(cr, version):
    try:
        cr.execute('ALTER TABLE carepoint_medical_prescription_order_line '
                   'RENAME TO carepoint_rx_ord_ln')
    except Exception:
        cr.rollback()
        _logger.exception('Cannot perform migration')

    try:
        cr.execute('ALTER TABLE carepoint_carepoint_organization '
                   'RENAME TO carepoint_org_bind')
    except Exception:
        cr.rollback()
        _logger.exception('Cannot perform migration')

Fix prescription migration * Add try/catch & rollback to db alterations in case server re-upgrades
[FIX] connector_carepoint: Fix prescription migration
* Add try/catch & rollback to db alterations in case server re-upgrades

+ 
+ import logging
+ 
+ _logger = logging.getLogger(__name__)
  
  
  def migrate(cr, version):
+     try:
-     cr.execute('ALTER TABLE carepoint_medical_prescription_order_line '
+         cr.execute('ALTER TABLE carepoint_medical_prescription_order_line '
-                'RENAME TO carepoint_rx_ord_ln')
+                    'RENAME TO carepoint_rx_ord_ln')
+     except Exception:
+         cr.rollback()
+         _logger.exception('Cannot perform migration')
  
+     try:
-     cr.execute('ALTER TABLE carepoint_carepoint_organization '
+         cr.execute('ALTER TABLE carepoint_carepoint_organization '
-                'RENAME TO carepoint_org_bind')
+                    'RENAME TO carepoint_org_bind')
+     except Exception:
+         cr.rollback()
+         _logger.exception('Cannot perform migration')
  
Fix prescription migration * Add try/catch & rollback to db alterations in case server re-upgrades
## Code Before:


def migrate(cr, version):
    cr.execute('ALTER TABLE carepoint_medical_prescription_order_line '
               'RENAME TO carepoint_rx_ord_ln')

    cr.execute('ALTER TABLE carepoint_carepoint_organization '
               'RENAME TO carepoint_org_bind')

## Instruction:
Fix prescription migration * Add try/catch & rollback to db alterations in case server re-upgrades
## Code After:

import logging

_logger = logging.getLogger(__name__)


def migrate(cr, version):
    try:
        cr.execute('ALTER TABLE carepoint_medical_prescription_order_line '
                   'RENAME TO carepoint_rx_ord_ln')
    except Exception:
        cr.rollback()
        _logger.exception('Cannot perform migration')

    try:
        cr.execute('ALTER TABLE carepoint_carepoint_organization '
                   'RENAME TO carepoint_org_bind')
    except Exception:
        cr.rollback()
        _logger.exception('Cannot perform migration')
