作者sean72 (.)
看板Python
標題Re: [問題] Django migrate
時間Thu Aug 18 13:21:51 2016
※ 引述《sean72 (.)》之銘言:
: 標題: [問題] Django migrate
: 時間: Thu Aug 18 11:34:27 2016
:
: 問題:migrate之後不會產生table
:
: 執行 makemigrations 然後 migrate之後
: 發現table會有一個前綴詞
: http://goo.gl/yJjtBC
: 於是手動把migrations folder刪掉 手動drop table
:
: 加入met class options之後
: 再次執行makemigrations 和 migrate
: 資料庫裏面卻不會產生table 我也沒看到 console有任何err
: 請問有人碰過這問題嗎?
:
: 謝謝
:
: --
: ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 172.89.32.145
: ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1471491270.A.F6E.html
: 推 billy0131: migrate過了以後光drop table不夠 08/18 13:11
: → billy0131: django有存一個table叫django_migration存你跑過的 08/18 13:12
: → billy0131: migration,那裡的狀態不對的話會有問題 08/18 13:12
: → billy0131: 像這個case應該先migrate回之前的版本再刪migrations 08/18 13:14
UPDATE
db is mySQL
after I updated PyMySQL to latest 0.7.6, everything works fine now
Thank you everyone
~~
嗯 我在stack overflow有看到這個回應 也嘗試過了 無效
我開了一個新的DB來測驗
只要有設定
class Meta:
managed = False
db_table = 'mytest'
就算是全新的DB也不會產生 mytest table
但是如果我不加db_table
就可以正常產生 mytest_mytest table
django version 1.8.3
這是不是一個bug ...
也許我直接升級 django 1.9 or 1.10試試看
~~
1.9 or 1.10 不支援python 3.3了...
把 db_table這個option拿掉 忍受醜醜的prefix ex: mytest_mytest
一切作用就正常了
若是硬要留著 db_table = mytest
這樣連基本的table 變動後 makemigration 都會說 no change detected
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 172.89.32.145
※ 文章網址: https://www.ptt.cc/bbs/Python/M.1471497713.A.E67.html
※ 編輯: sean72 (172.89.32.145), 08/18/2016 13:40:34
※ 編輯: sean72 (172.89.32.145), 08/18/2016 14:10:19
※ 編輯: sean72 (172.89.32.145), 08/18/2016 14:21:00
推 a0919610611: 我1.9 用mysqlclient 能解決中文也沒遇到啥問題過 08/18 15:31
→ a0919610611: py3.5 08/18 15:31
推 billy0131: 不會產生新的table應該跟managed=False有關 08/18 23:20
→ billy0131: 要不要拿掉試試看? 我在1.8跟1.9加db_table都可偵測到 08/18 23:21