Migrating data between different schemas

有些话、适合烂在心里 提交于 2021-01-29 20:17:32

问题


I have a small django website where people have signed up and uploaded pictures and stuff.

I now want to rebuild the website API. This will change the database schema and I want to migrate all the user information from old database to new database.

Whats the best practice of doing this? Links to tutorials will be helpful.

The database backend is postgres-postgis.

TIA


回答1:


There are different approaches to data migration. In my previous employer we rewrote much of the code from scratch and before deploying the new application we had to migrate old data. Two methods are:

  1. Migrate data from the first schema directly from the DB: This is very useful especially if the data you have in legacy DB is huge. If you let the DB copy from one table/database to another it will be extremely fast. You need to have SQL knowledge for this though (google 'insert into from another database').

  2. Write a script or django command to load the data into django models and go from there. This will not be as fast as DB option but it may be easier to code and depending on your scale of changes, your only option. If you are going to do some computation beforehand then a high level language such as python will be helpful.



来源:https://stackoverflow.com/questions/21456575/migrating-data-between-different-schemas

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!