Django: Getting Started Transcripts
Chapter: DB Migrations
Lecture: Adding a column to the 'Song' model

Login or purchase this course to watch this video and the rest of the course contents.
0:05 That's my new field. Let me make migrations again. I spoke earlier about how changes to the table impact the existing data in the table.
0:27 Because artist's name wasn't specified to allow null. The database has to put something in there when it creates the column for any existing data.
0:35 Now there's no data in this case, but it doesn't know that and it's trying to protect you.
0:41 I'm going to choose provide a one off default and provide the empty string. If there had been data in the table,
0:51 any rows that existed would get the empty string as their value for the new artist name column. And the result of all this is a new file showed up in
1:04 the migrations directory. 0002 song artist name. The naming structure here is a number which indicates an order of running,
1:15 then the model name and some detail about the change for a column, add, it shows the name of the column. Let's take a look at it.


Talk Python's Mastodon Michael Kennedy's Mastodon