On Oct 31, 2012, at 4:32 PM, junepeach wrote:

> Hi Michael,
> 
> I have several views defined in alembic migration script, and so I defined 
> op.execute('drop view xxx') to drop all of my view sql files. When I ran 
> script 'alembic downgrade -1' to drop all of the tables, views, indexes, 
> MySQL, SQLITE3 worked fine. When working with Postgresql, I got below:
> qlalchemy.exc.InternalError: (InternalError) cannot drop table tbl_1 because 
> other objects depend on it
> DETAIL:  view view_1 depends on table tbl_1
> HINT:  Use DROP ... CASCADE to drop the dependent objects too.
> '\nDROP TABLE tbl_1' {}
> 
> Does sqlalchemy/alembic support 'drop table xxx cascade' for most databases?

the "DROP..CASCADE" thing is a Postgresql thing.  The command will do something 
different on Postgresql than the other backends; it will drop other objects as 
well.

So you might want to make sure you're dropping all the things the view is 
dependent on, also, for cross-platform compatibility.

I thought we had a flag for the "CASCADE" thing but we currently don't.  
There's ways to get that but I think you need to drop the views directly here.


-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to