关于django正确部署heroku删除数据库求教,djangoheroku,model 中新增了一个
关于django正确部署heroku删除数据库求教,djangoheroku,model 中新增了一个
model 中新增了一个对象 Message 和 并在另一个model中增加外键字段message,然后push到heroku上,同步migrate之后,发现新的表不能用. 但是本地是执行 python manage.py flush 之后同步的,没出问题, 但是在heroku上执行 flush 出错
CommandError: Database d4e4561s5hscht couldn't be flushed. Possible reasons: * The database isn't running or isn't configured correctly. * At least one of the expected database tables doesn't exist. * The SQL was invalid.Hint: Look at the output of 'django-admin sqlflush'. That's the SQL this command wasn't able to run.The full error: cannot truncate a table referenced in a foreign key constraintDETAIL: Table "blog_post" references "auth_user".HINT: Truncate table "blog_post" at the same time, or use TRUNCATE ... CASCADE.
请问怎么清理数据库
「blog_post」表中有字段外键关联到了 「auth_user」 表。
flush是truncate table的,auth_user表有数据当然不能truncate。
现版本通常的做法是:
python manage.py makemigrationspython manage.py migrate
这样就可以了啊,不知道LZ说的「migrate之后,新的表不能用」是什么意思
为什么要flush呢? 都已经上线了 还要清数据?
编橙之家文章,
相关内容
- Python类的参数接受实例吗?,python类参数实例,a = Acla
- Python什么方法卸载比较正确,python卸载,刚接触python,有
- Python批量下载服务器文件并保存的脚本思路,python脚本
- Python3下载rar文件打开报错求解,python3rar,点击某个链接
- Python2.7转义问题例如x='C:\py\code'如何操作,python2.7py,我
- 《learn python the hard way》这句话理解和翻译是什么,,翻
- 求Python celery原理大神帮解释,pythoncelery,什么是异步任
- Python判断编码不是很理解,python判断编码,pythondef is
- 问Python中open函数是一次性载入内存吗,pythonopen,背景:
- win7 64 python pip安装遇到问题求助,win7pip,我的python是2
评论关闭