Let Django’s migration run raw SQL

You’ve created a new column and you want set its value as the "id" column. What to do? 

Add the following line to the generated migration file or you can create new migration file

migrations.RunSQL(sql="update some_table set new_column = id")

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.