How can I easily convert a Django app from mySQL to PostgreSQL?

后端 未结 7 1894
一个人的身影
一个人的身影 2021-01-31 12:04

Has anyone done this? Is it an easy process? We\'re thinking of switching over for transactions and because mysql seems to be \"crapping out\" lately.

7条回答
  •  -上瘾入骨i
    2021-01-31 12:14

    I wrote a Django management command that copies one database to another: https://gist.github.com/mturilin/1ed9763ab4aa98516a7d

    You need to add both database in the settings and use this command:

    ./manage.py copy_db from_database to_database app1 app2 app3 --delete --ignore-errors
    

    What cool about this command is that it recursively copy dependent objects. For example, if the model have 2 foreign keys and two Many-to-Many relationships, it will copy the other objects first to ensure you won't get foreign key violation error.

提交回复
热议问题