Migrations secret powers ⚡
summary
Django migrations can separate model state changes from database operations using SeparateDatabaseAndState to tell Django a model was removed while running optimized SQL to rename the existing table into the auto-generated many‑to‑many name. The workflow uses a blank migration with run_sql and RunPython (functions take apps and schema_editor and must use apps.get_model), often with noop for irreversibility. Watch for PostgreSQL atomicity limits, manually determine db_table names from migration files or model._meta.db_table, and prefer reversible steps when feasible.
AI-written summary · about
