Reduce the table name length to below 50 characters
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)
-
-
reporter That might explain why the issue has remained when previously I've tried to shorten the longest table names.
-
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?
-
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!
-
It is here: https://github.com/django/django/commit/8ce3c3a9282ac19282060ddf6928b34a09d26672 but looks like all it does is validate them.
I don't know why django insists on 50 characters. It seems daft.
-
reporter - changed status to open
-
reporter Refactored Size_upload to SizeUpload. Refs
#62→ <<cset 54e2a05b7754>>
-
reporter Corrected Content_item_descriptions to ContextID, satisfying PEP 8 and correcting a very old mistake in the process! Refs
#62.→ <<cset 69b53d28d391>>
-
reporter Renamed General_study_module_attributes to GeneralStudyModuleAttr. Refs
#62→ <<cset 03a8aa0b2714>>
-
reporter -
assigned issue to
- edited description
- changed milestone to 0.5.1
-
assigned issue to
-
reporter Changed Projection_xray_radiation_dose, Accumulated_xray_dose & Irradiation_event_xray_data to ProjectionXRayRadiationDose, AccumulatedXRayDose & IrradiationEventXRayData respectively. Refs
#62.→ <<cset 8423bb4c9785>>
-
reporter Image_view_modifier to ImageViewModifier. Refs
#62→ <<cset 37e96ae93653>>
-
reporter Irradiation_event_xray_detector_data
,Irradiation_event_xray_source_data
andIrradiation_event_xray_mechanical_data
toIrradEventXRayDetectorData
,IrradEventXRaySourceData
andIrradEventXRayMechanicalData
respectively.IrradiationEventXRayData
toIrradEventXRayData
for consistency, as other modals were still too long as CamelCase. Refs#62.→ <<cset b0a98b628fe0>>
-
reporter Accumulated_cassette_based_projection_radiography_dose
andAccumulated_integrated_projection_radiography_dose
toAccumCassetteBsdProjRadiogDose
andAccumIntegratedProjRadiogDose
respectively. They were the longest model names. Refs#62→ <<cset 6005fe3c6be4>>
-
reporter All the accumulated models reduced.
AccumulatedXRayDose
reduced further for consistency with the others. Refs#62→ <<cset b0fbbc4a1c4f>>
-
reporter Changed all the models beginning with
Ct
. Couldn't useCT
unfortunately as that breaks CamelCase convention. Will have to change the ones namedXRay
. Refs#62→ <<cset 075e9a2eb530>>
-
reporter XRay
doesn't break CamelCase rule if it is not the first word, asCT
was. So changedCtXraySourceParameters
toCtXRaySourceParameters
. Refs#62→ <<cset 528de4e48269>>
-
reporter Renamed
Device_participant
andPerson_participant
. Refs#62→ <<cset c6177290ede1>>
-
reporter Renamed
Dose_related_distance_measurements
andGeneral_equipment_module_attributes
. Refs#62→ <<cset c5599fa19024>>
-
reporter - changed status to resolved
Finished the models converting to CamelCase and ensuring lengths less than 33. Fixes
#62but needs testing.→ <<cset 2dea3d41962c>>
-
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.
-
reporter Migration of all the non-table-name-change elements. Refs
#172,#62, #55,#154→ <<cset 3852d6411044>>
-
reporter Adding the migration file with the add/delete tables in to use as a basis to create a rename version. Refs
#172,#62, #55,#154.→ <<cset ceb9f748d1d8>>
-
reporter Adding the start of a migration file with rename tables. Refs
#172,#62, #55,#154. Need to remember to deal with foreign keys at the same time→ <<cset 281df1155512>>
-
reporter Added start of a backwards migration. Refs
#172,#62, #55,#154. Need to remember foreign keys→ <<cset 8ce41df46f33>>
-
reporter Added SizeUpload, GeneralEquipmentModuleAttr, AccumCassetteBsdProjRadiogDose, PulseWidth and PersonParticipant in both directions. Refs
#62→ <<cset 8253282b524f>>
-
reporter Added ProjectionXRayRadiationDose, IrradEventXRaySourceData, CtAccumulatedDoseData, DeviceParticipant and ImageViewModifier in both directions. Refs
#62→ <<cset 7e16237b6f70>>
-
reporter Added ScanningLength, AccumXRayDose, IrradEventXRayMechanicalData, XrayTubeCurrent, XrayFilters, XrayGrid and ContextID in both directions. Refs
#62→ <<cset d605a020703f>>
-
reporter Added AccumMammographyXRayDose and ObserverContext in both directions. Refs
#62→ <<cset c13cdebace39>>
-
reporter Added AccumIntegratedProjRadiogDose, CtXRaySourceParameters, GeneralStudyModuleAttr and DoseRelatedDistanceMeasurements in both directions. Refs
#62→ <<cset bca4390c8f22>>
-
reporter Added IrradEventXRayDetectorData, CtIrradiationEventData, IrradEventXRayData and PatientModuleAttr in both directions. Refs
#62→ <<cset 9b1b4ed2c038>>
-
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. ;-) -
reporter Changed field SizeUpload in 0.5.1ChangeModelNamesOnly branch. Refs
#62.→ <<cset a2f390445a66>>
-
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.
-
reporter Perfect. Thanks :)
-
reporter Changed about half the model names to the new versions. Refs
#62.→ <<cset 2460b6fc2515>>
-
reporter Added a few more. Corrected AccumXRayDose to AccumProjXRayDose, hopefully correctly, so that the real AccumXRayDose could be updated... Refs
#62→ <<cset 92b40a5f037e>>
-
reporter Finished renames. Now need to create a migration file... Refs
#62→ <<cset 492e95e80ccf>>
-
reporter New base file for migration of model names. No other changes to models. Includes ContentTypes in the freeze. Refs
#62.→ <<cset 11c432cec468>>
-
reporter Continuation of adding ForeignKey changes. Refs
#62→ <<cset 24d4384cfc7a>>
-
reporter Finished IrradEventXRayData ForeignKeys. Refs
#62→ <<cset 5d1a43794a8f>>
-
reporter A few more ForeignKeys completed. Refs
#62→ <<cset 95f3ccf12cfb>>
-
reporter Completed the forwards ForeignKey changes. Need to reverse. Refs
#62→ <<cset a7a2a56daa69>>
-
reporter Starting to put the reverse ForeignKey alterations in. Refs
#62→ <<cset 0f6a3ecabb71>>
-
reporter Adding another couple of tables of ForeignKeys for the backwards migration. Refs
#62→ <<cset 6308bf945f46>>
-
reporter Finished ForeignKey backwards code. Refs
#62→ <<cset 137df3e1eedc>>
-
reporter Merged the forward and backward change name code with the auto-generated freeze code. Refs
#62→ <<cset 4ad7a73ed280>>
-
reporter Corrected mistake renaming both the projection and general accumulated versions to the general. Refs
#62→ <<cset a0559b0bb391>>
-
reporter Removed all the backwards stuff as it will not be possible to revers the migration in most instances. Refs
#62→ <<cset d93059fe510d>>
-
reporter Changed model name to resolve inconsistencies between the model name change branch and the dev branch. Refs
#62.→ <<cset fdb235eb2649>>
-
reporter Correcting some of the model names that didn't get changed in the refactoring. Refs
#62→ <<cset 03134ad47cbc>>
-
reporter Corrected error in name of ctradiationdose source_of_dose_information_id field that had prevented the migration. Refs
#62→ <<cset 262331916c75>>
-
reporter - changed status to resolved
Fixes
#62. Needs extensive testing and documentation (refs#184)→ <<cset 0891169161a9>>
- Log in to comment
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.