Amandasaurus
Amandasaurus

Reputation: 60699

Dropping the 'table' for a model and recreating in a django south migration

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?

Upvotes: 3

Views: 1448

Answers (1)

Martin Maillard
Martin Maillard

Reputation: 2811

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...

Upvotes: 2

Related Questions