#Migration failing on renaming (ms sql 2019)

6 messages · Page 1 of 1 (latest)

dark valve
#

hello! I am having a bit of an issue sorting out a migration issue, as it is working for other databases fine just for some reason it isn't liking MS SQL 2019.
The previous migration sets up the table
migrations.CreateModel( name='table', fields=[ ... ('old\_name', models.PositiveIntegerField(choices=[(1, 'option\_1'), (2, 'option\_2'), (4, 'option\_3'), (8, 'option\_4'), (16, 'option\_5')], default=(1, 'option\_1'))), ... ], ),
and the migration with the renaming
migrations.RenameField( model\_name='table', old\_name='old\_name', new\_name='new\_name', ),
The error it is outputting is
TypeError: Field 'old\_name' expected a number but got (1, 'option\_1').

It works fine on sqlite3 and mysql, but as I need to use ms sql 2019 I need to either figure this out or just clean out the migrations folder and just make a new primary setup.

The column is showing up in ms sql as an int

Any advice would be really appreciated aww

snow tangle
#

Are you able to share more of the error?

nocturne granite
#

you could potentially "rename" a field by adding the new field, copying all data via a RunPython step to it and then removing the original field, so 3 operations instead of one

dark valve