Reduce the table name length to below 50 characters

Issue #62 resolved
Ed McDonagh
created an issue

Actual limit is 39 characters, as the auth module uses some of the 50. The 39 includes remapp_ which takes up another seven characters, leaving 32 for the modal name.

Modal names can partly be made shorter by using CamelCase, and at the same time that comes into line with PEP 8 naming conventions.

Some will also need to be abbreviated.

Comments (53)

  1. Jonathan Cole

    Auth_permissions adds up to 11 characters to the names for "Can delete" etc. Might need names of 39 characters or less. It seems to be a running issue with django from what I can tell.

  2. Jonathan Cole

    The new version 1.7 of django has a fix for this issue and is due to be released in May.

    It's difficult. If the names are going to be changed, better to do so now before we write a load more views that reference them. However, if there is a simple interim fix and a proper fix coming soon, is it worth messing with the existing models?

  3. Ed McDonagh reporter

    Have you got a link to the 1.7 fix?

    I'm tending to agree with you though, we should just get rid of the problem. I hadn't thought about changing all the views etc. Bummer!

  4. Ed McDonagh reporter
    • changed status to open

    Database migration required due to #55 and #154 modifications to the models failed on my PostgreSQL database due to this old issue. Therefore going to refactor all the models to reduce their length and comply with the PEP 8 naming conventions (Classes should use CamelCase).

  5. Ed McDonagh reporter

    Irradiation_event_xray_detector_data, Irradiation_event_xray_source_data and Irradiation_event_xray_mechanical_data to IrradEventXRayDetectorData, IrradEventXRaySourceData and IrradEventXRayMechanicalData respectively. IrradiationEventXRayData to IrradEventXRayData for consistency, as other modals were still too long as CamelCase. Refs #62.

    → <<cset b0a98b628fe0>>

  6. Ed McDonagh reporter

    Accumulated_cassette_based_projection_radiography_dose and Accumulated_integrated_projection_radiography_dose to AccumCassetteBsdProjRadiogDose and AccumIntegratedProjRadiogDose respectively. They were the longest model names. Refs #62

    → <<cset 6005fe3c6be4>>

  7. Ed McDonagh reporter
    • changed status to open

    South can't do renaming automatically it seems, so a South migration would have to be manually edited to convert all the delete/add commands into rename ones. Back to the drawing board.

  8. Ed McDonagh reporter

    I've now tested a rename now with foreign keys in a renamed model and it all works ok. One of the key things is to have a schemamigration --auto --freeze=contenttypes to get a freeze with the content types at the bottom of the migration file. Now need to go back to 0.5.0, change only the model names, get that migration sorted, then make all the other changes and add them to the migration. Easy. ;-)

  9. David Platten

    Hi @Ed McDonagh. Thanks to my new ability to restore backup files, I have a mirror of my live system running on a stand-alone computer. I'm very happy to test your migration to the new shorter table names on this system when you're ready.

  10. Log in to comment