[์˜ค๋ฅ˜ํ•ด๊ฒฐ๐Ÿ› ๏ธ] Django makemigrations 'It is impossible to add a non-nullable field 'ํ•„๋“œ๋ช…' to certification without specifying a default. '

ํ•œ์ง€์›ยท2024๋…„ 7์›” 4์ผ

๋‚˜๋งŒ์˜ ์‚ฌ์ „

๋ชฉ๋ก ๋ณด๊ธฐ
8/26
post-thumbnail

๐Ÿ› ๏ธ ์˜ค๋ฅ˜ ํ˜„์ƒ

๐Ÿงจ ์˜ค๋ฅ˜ ๋ฐœ์ƒ

It is impossible to add a non-nullable field 'record' to certification without specifying a default. This is because the database needs something to populate existing rows.
Please select a fix:
 1) Provide a one-off default now (will be set on all existing rows with a null value for this column)
 2) Quit and manually define a default value in models.py.
Select an option: 

๐Ÿ“‹ ์˜ค๋ฅ˜ ์ฝ”๋“œ

python manage.py makemigrations

๐Ÿงฉ์˜ค๋ฅ˜ ์›์ธ

๋ฐฑ์—์„œ ๊ธฐ์กด ์ž‘์„ฑ๋œ models.py๋ฅผ ์ˆ˜์ •ํ•˜์…จ๋Š”๋ฐ ๊ทธ๊ฑธ ๋ชจ๋ฅด๊ณ  ๊ทธ๋ƒฅ makemigrations๋ฅผ ํ•˜๋‹ˆ ๋ฐœ์ƒํ•œ ์—๋Ÿฌ์˜€๋‹ค. ๊ตฌ๊ธ€๋งํ•ด๋„ ์ž˜ ์•ˆ ๋‚˜์™€์„œ ์˜ค๋ฅ˜ ์›์ธ์ด ๋น„์Šทํ•œ ๋‹ค๋ฅธ ์—๋Ÿฌ ํ•ด๊ฒฐ๋ฐฉ๋ฒ•์„ ์‚ฌ์šฉํ–ˆ๋‹ค...


๐Ÿ”‘ ์˜ค๋ฅ˜ ํ•ด๊ฒฐ

  1. cd migrations
  2. 0001_initial.py ์™€ ๊ฐ™์€ ํ˜•ํƒœ์˜ ํŒŒ์ผ์„ ์‚ญ์ œํ•œ๋‹ค.
    rm 0001_initial.py 
    rm 0002_some_change.py
  3. python manage.py makemigrations
profile
์ฒœ์ฒœํžˆ ์˜ฎ๊ธฐ๋Š” ์ค‘

0๊ฐœ์˜ ๋Œ“๊ธ€