更改postgres数据库中表的列标题

2024-06-17 09:23:49 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试重命名数据库中的列

是的

heroku pg:psql

ALTER TABLE discounts_discount RENAME COLUMN percentagediscountm TO percentagediscount

这没有任何影响。我查看了一些网站,就我所知,我上面写的应该是有效的

enter image description here

我尝试使用make migrations和migrate进行更改,但随后出现了此错误

django.core.exceptions.FieldDoesNotExist: discounts.discount has no field named 'percentagediscountm'

enter image description here

我真的在努力避免删除数据库或将Heroku回滚到早期版本


Tags: to数据库heroku网站tablecolumndiscount重命名
1条回答
网友
1楼 · 发布于 2024-06-17 09:23:49

您可以输入相同的命令,并在末尾使用;。这应该是可行的:

ALTER TABLE discounts_discount RENAME COLUMN percentagediscountm TO percentagediscount;

您可以查看Here以获得有关它如何不工作的详细信息

相关问题 更多 >