django-rename-app icon indicating copy to clipboard operation
django-rename-app copied to clipboard

Don't attempt to rename table if it doesn't exist

Open dodget opened this issue 2 years ago • 0 comments

Thanks for this package, it was a big help! One thing I noticed while trying to use it is that the following query was tripping up on models/tables that had been removed at some point from the original app:

query = (
    f'ALTER TABLE "{old_table_name}" '
    f'RENAME TO "{new_table_name}"'
)

Adding IF EXISTS to the query helped to skip tables that no longer exist.

query = (
    f'ALTER TABLE IF EXISTS "{old_table_name}" '
    f'RENAME TO "{new_table_name}"'
)

I can fork and submit a PR if you'd like.

dodget avatar Feb 21 '23 15:02 dodget