首页 > 解决方案 > 在 Django 模型中删除新列或删除现有表时如何保留以前的数据?

问题描述

我正在与开发人员组一起开发 ERP,我们需要在删除 Dajngo 模型和数据库的现有列或表时保留客户数据。

例如:

I added a column named columns1 and I gave the customer a release product of the System and then, but a week later I had to delete that new column but the customer have data stores in the column1 column, here how can I preserve data or solve this situation.

Another Example:

I have a new column name column2 with unique attr but here the customer have data, but I can not add new column with out allowed it to store the null data, but in this situation I do not want to allow the null data in column column2 and ether I can't put default attr because it has unique attr.

How to solve these things in Django.

标签: pythondjango

解决方案


我认为你需要在表字段名称中添加一个布尔字段删除如果你想删除列不要删除它把删除字段值设置为true。当您查询时添加条件删除 = false 的过滤器。我认为这适用于第一个条件


推荐阅读