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. Ed McDonagh reporter

    That might explain why the issue has remained when previously I've tried to shorten the longest table names.

  3. 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?

  4. 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!

  5. 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).

  6. Ed McDonagh reporter

    Changed Projection_xray_radiation_dose, Accumulated_xray_dose & Irradiation_event_xray_data to ProjectionXRayRadiationDose, AccumulatedXRayDose & IrradiationEventXRayData respectively. Refs #62.

    → <<cset 8423bb4c9785>>

  7. 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>>

  8. 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>>

  9. Ed McDonagh reporter

    Changed all the models beginning with Ct. Couldn't use CT unfortunately as that breaks CamelCase convention. Will have to change the ones named XRay. Refs #62

    → <<cset 075e9a2eb530>>

  10. Ed McDonagh reporter

    XRay doesn't break CamelCase rule if it is not the first word, as CT was. So changed CtXraySourceParameters to CtXRaySourceParameters. Refs #62

    → <<cset 528de4e48269>>

  11. 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.

  12. Ed McDonagh reporter

    Added SizeUpload, GeneralEquipmentModuleAttr, AccumCassetteBsdProjRadiogDose, PulseWidth and PersonParticipant in both directions. Refs #62

    → <<cset 8253282b524f>>

  13. Ed McDonagh reporter

    Added ProjectionXRayRadiationDose, IrradEventXRaySourceData, CtAccumulatedDoseData, DeviceParticipant and ImageViewModifier in both directions. Refs #62

    → <<cset 7e16237b6f70>>

  14. Ed McDonagh reporter

    Added ScanningLength, AccumXRayDose, IrradEventXRayMechanicalData, XrayTubeCurrent, XrayFilters, XrayGrid and ContextID in both directions. Refs #62

    → <<cset d605a020703f>>

  15. Ed McDonagh reporter

    Added AccumIntegratedProjRadiogDose, CtXRaySourceParameters, GeneralStudyModuleAttr and DoseRelatedDistanceMeasurements in both directions. Refs #62

    → <<cset bca4390c8f22>>

  16. 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. ;-)

  17. David Platten

    Hi @edmcdonagh. 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.

  18. Ed McDonagh reporter

    Added a few more. Corrected AccumXRayDose to AccumProjXRayDose, hopefully correctly, so that the real AccumXRayDose could be updated... Refs #62

    → <<cset 92b40a5f037e>>

  19. Log in to comment