← Back to team overview

credativ team mailing list archive

[Bug 953468] Re: rename_columns should have extra checks

 

I was thinking that since pre-/post- scripts can be run multiple times
and to make resiliant I was about to write:

    if openupgrade.table_exists(cr, 'res_partner_job') and \
    not openupgrade.column_exists(cr, 'res_partner_job', 'target') and \
    openupgrade.column_exists(cr, 'res_partner_job', 'source'):
        openupgrade.rename_column(cr, rename_column)

at that point I though..... surely we can do with:

   openupgrade.rename_column(cr, rename_column, failsave=True)

If you want to keep default functions 'failing'.

Plus the return value of the above can be stored and tested weather to
execute the rest of pre-/post- migration.

This makes code clearer and easier to understand:
- attempt first rename
- check if it is possible
- fail loudly or return useful return value
- based on return value, do not execute the rest

Ideally I do not want to use try & except blocks.
I'd rather have migration check for everything it can and raise exception to abort the whole migration.

-- 
You received this bug notification because you are a member of
OpenUpgrade Committers, which is the registrant for OpenUpgrade Server.
https://bugs.launchpad.net/bugs/953468

Title:
  rename_columns should have extra checks

Status in OpenUpgrade Server:
  Confirmed

Bug description:
  - check that table_exists
  - check that target column does not exist
  - check that source column exist

  and return:
   True if the rename is actually performed
   False otherwise

  Maybe some added verbose logging.

To manage notifications about this bug go to:
https://bugs.launchpad.net/openupgrade-server/+bug/953468/+subscriptions


References