You have a model Booking that is referenced by another model by m2m field(Product.bookings). Now you want to change name of model Booking to Payment and Product.bookings should be change to payments.
When you run make migrations, it shows Remove field first and then Add field. If you want to keep data while change names, how would you do it seamlessly?
If there’s any related discussion, forward me please. Thank you.
I ended up doing renaming Booking model and insert data before m2m tables are deleted.
Generated migration files by command first execute RemoveField on Product.bookings and then AddField Product.payments. Instead I put AddField first and then RemoveField later. Then between them I add RunSQL with insert statement, both in sql and reverse_sql.
Crucial thing is that I put old table name when doing INSERT INTO, because by the time RunSQL is run new m2m table has already been created. That looked weird because the fields and table names are not in sync with final state, but that’s the way to go.