2013-12-23 172 views
5

我目前沒有在我的Django項目中使用遷移,但我打算很快。據我所知,South是事實上的工具,我打算使用它,但後來我在Django項目網站上看到開發版本(我猜想發佈爲1.7)有一個核心遷移工具,運行時爲migrateDjango的核心遷移工具與南方的Django數據遷移

來自使用遷移工具的很少經驗(我在南方安裝了Django-CMS並在它上面玩了一天左右),這對於初學者來說是最好的嗎?

另外,由於遷移本身非常年輕,而且Django的版本更加如此,那麼在南方這點上我會更好嗎?

最後,另一個問題是,如果我從南開始(我的大部分Django項目都是v1.5),當我升級到1.6然後升級到1.7時,我會無法轉換爲Django的核心遷移?

+0

相關問題:如何提供從南應用程序到Django 1.7遷移的升級路徑http://stackoverflow.com/questions/22597240/upgrade-path-for-re-usable-apps-with-south-and-django -1-7遷移 – stefanfoulis

回答

3

它容易丟棄南遷移歷史並初始化任何其他類型的遷移工具。

Django核心遷移基於南,所以我猜測它將有可能將南遷移歷史導出到Django核心遷移。

由於Django核心遷移還沒有發佈,而你的目的是學習,所以我建議從南開始。

+0

我安裝了南部並轉換了我的應用程序,它運行得很好。由於我還沒有準備好升級Django,所以這個計劃似乎是個好主意。謝謝。 – nicorellius

4

由於安德魯戈德溫(創造者或Django核心遷移)關於這一變化的話是:「南的四年設計嚴重的限制,是時候增加遷移支持到Django本身」,我不會賭將南遷移歷史導出到Django核心遷移的能力。這就是爲什麼,如果可以的話,我建議你等待1月20日:核心遷移的Django 1.7 alpha版本將被髮布,你可以看到here

最終,Andrew Godwin worked on South himself,所以你不應該看到Django Core Migration作爲一個整體的新工具,而是作爲South v2。

然後,你可以很確定,只要Core遷移發佈,South就不會真正維護。

這就是爲什麼我建議等待一些時間,並給予一個機會,這個新工具:)

+0

好點+1 ... – nicorellius

3

從南Django的1.7升級討論的文件:

If you already have pre-existing migrations created with South 0.x, then the upgrade process to use django.db.migrations is quite simple:

  • Ensure all installs are fully up-to-date with their migrations
  • Delete all your (numbered) migration files, but not the directory or init.py - make sure you remove the .pyc files too.
  • Run python manage.py makemigrations. Django should see the empty migration directories and make new initial migrations in the new format.
  • Run python manage.py migrate. Django will see that the tables for the initial migrations already exist and mark them as applied without running them.

That’s it! The only complication is if you have a circular dependency loop of foreign keys; in this case, makemigrations might make more than one initial migration, and you’ll need to mark them all as applied using:

python manage.py migrate --fake yourappnamehere 

(從here)。

+0

> Django會看到初始遷移的表已經存在,並將它們標記爲已應用而不運行它們。 顯然,並不總是如此。我收到錯誤「django.db.utils.OperationalError:table」[table]「already exists」。正在運行遷移應用程序0001 --fake會修復它。 – wes