删除“表”;用于模型并在 django 南迁移中重新创建
我有一个 Django 模型,它是使用一些自定义 sql 创建的。它实际上只是一个 SQL 视图,而不是一个真正的表。我们使用 django South 来管理迁移。我更改了视图定义 SQL,并且想为此更改编写迁移。
因为它只是一个 sql 视图,如果我删除该视图,然后“重新创建”它(通过运行自定义 sql),那么该视图将更新为新定义,显然我们不会丢失任何数据。我怎样才能在 django South 做到这一点?
在 django South 中删除表/视图很容易,我可以调用一些原始 SQL db.execute*("DROP VIEW view_name;") ,有更好的方法吗?
有没有办法从对象重新创建表?像orm.MyTable.recreate_this_table()
之类的东西,以便它将使用自定义sql文件?
I have a django model which is created using some custom sql. It's actually just a SQL view, it's not a real table. We are using django south to manage migrations. I have changed the view definition SQL, and I want to write a migration for this change.
Since it's just a sql view, if I drop the view, then 'recreate' it (by running the custom sql), then the view will be updated to the new defintion and we, obviously won't lose any data. How can I do that in django south?
Deleteing the table/view is easy in django south, I could just call some raw SQL db.execute*("DROP VIEW view_name;")
, is there a better way?
Is there a way to recreate the table from an object? something like orm.MyTable.recreate_this_table()
, so that it'll use the custom sql file?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如何在 Django/South 中处理数据库视图 似乎包含有关此问题的一些好信息。至于你问题的结尾,我不确定我明白你想做什么......
How to handle database views in Django/South seems to contain some good information about this issue. As for the end of your question, I'm not sure I understand what you want to do...