Thanks dude, very cool explanation, but I don't understand what the second SQL query in the 9:00 migration is responsible for, the one with the “blog_article_authors” line, we are migrating one table, why do we need to copy data for two? The reverse query: Is “reverse_sql” required? What if I only need to transfer once?
Hey thanks for watching the video.The second SQL query is selecting data from the old bridge table (article_authors) and insert it into the new bridge table (blog_article_authors). The bridge table or through table is used to represent the m2m relationship in models (django has documentation talking about through table). I think it will make sense if you look at the actual database, and try to match the fields in the models to the columns in the table. As of the 'reverse_sql' argument, it is not required, this is to help you rollback on your database. I made another video talking about this (title: django database rollback). Also, instead of rollback, you can also just keep making forward migrations to fix any issue you have in your database. Let me know if this made sense. Just curious, how did you stumble upon this video?
@@strikeitbroke3602 Thanks, everything worked; I needed to migrate several tables with several ForeignKeys and m2m. I encountered a bug (or maybe not): If the table name is capitalized, DB does not recognize it: django.db.utils.ProgrammingError: relation “district_model” does not exist LINE 115: FROM District_Model; Although it definitely existed, I checked it by renaming it to: district_model and everything worked, even though I left this name in the migration file. As for how I found your video, I needed to transfer a table, so I wrote something like “how to transfer a model in Django to a new app,” and your video was the first) Great explanation on the new versions of Django; keep it up, thanks)!
Thanks dude, very cool explanation, but I don't understand what the second SQL query in the 9:00 migration is responsible for, the one with the “blog_article_authors” line, we are migrating one table, why do we need to copy data for two?
The reverse query: Is “reverse_sql” required? What if I only need to transfer once?
Hey thanks for watching the video.The second SQL query is selecting data from the old bridge table (article_authors) and insert it into the new bridge table (blog_article_authors). The bridge table or through table is used to represent the m2m relationship in models (django has documentation talking about through table). I think it will make sense if you look at the actual database, and try to match the fields in the models to the columns in the table.
As of the 'reverse_sql' argument, it is not required, this is to help you rollback on your database. I made another video talking about this (title: django database rollback). Also, instead of rollback, you can also just keep making forward migrations to fix any issue you have in your database. Let me know if this made sense.
Just curious, how did you stumble upon this video?
@@strikeitbroke3602 Thanks, everything worked; I needed to migrate several tables with several ForeignKeys and m2m.
I encountered a bug (or maybe not): If the table name is capitalized, DB does not recognize it:
django.db.utils.ProgrammingError: relation “district_model” does not exist
LINE 115: FROM District_Model;
Although it definitely existed, I checked it by renaming it to:
district_model and everything worked, even though I left this name in the migration file.
As for how I found your video, I needed to transfer a table, so I wrote something like “how to transfer a model in Django to a new app,” and your video was the first)
Great explanation on the new versions of Django; keep it up, thanks)!