Changes between Initial Version and Version 1 of Ticket #31186
- Timestamp:
- Jan 20, 2020, 1:36:47 PM (5 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #31186
- Property Type Uncategorized → Bug
-
Ticket #31186 – Description
initial v1 1 1 Hi, I think I have discovered a bug, if you have a field like the following: 2 {{{ 2 3 audio_name = models.CharField(blank=False, max_length=255) 4 }}} 3 5 and decide to change it to the following one: 4 6 {{{ 5 7 audio_name = models.TextField(blank=False) 6 8 }}} 7 9 it generates the following migration code: 8 10 {{{ 9 11 operations = [ 10 12 migrations.AlterModelOptions( … … 12 14 options={}, 13 15 ), 14 16 migrations.AlterField( 15 17 model_name='s3_bucket_audios', 16 18 name='audio_name', … … 22 24 ), 23 25 ] 24 26 }}} 25 27 However it that field was being use in a unique condition: 26 class Meta: 28 {{{ 29 class Meta: 27 30 ordering = [ "audio_name"] 28 31 unique_together = ('audio_name') 29 32 }}} 30 33 you get the following error: 34 {{{ 31 35 django.db.utils.OperationalError: (1170, "BLOB/TEXT column 'audio_name' used in key specification without a key length") 32 36 }}} 33 37 That is because it changes the field type before changing the unique condition, I think the order should be handled automatically, I had to change the code manually to: 34 38 {{{ 35 39 operations = [ 36 40 migrations.AlterModelOptions( … … 42 46 unique_together=set(), 43 47 ), 44 48 migrations.AlterField( 45 49 model_name='s3_bucket_audios', 46 50 name='audio_name', … … 48 52 ), 49 53 ] 54 }}} 50 55 51 56 It is not a big issue anyway...