Re: [sqlalchemy] Failed to drop view when working with Postgresql in alembic migration script

2012-11-01 Thread junepeach
Thanks Michael, it is very helpful :) -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/5FBLqMhwloQJ. To post to this group, send email to sqlalchemy@googlegroups

Re: [sqlalchemy] Failed to drop view when working with Postgresql in alembic migration script

2012-11-01 Thread Michael Bayer
On Nov 1, 2012, at 1:12 PM, junepeach wrote: > Yes, it is true for the view, but I also got below error when a view > references tables: > > qlalchemy.exc.InternalError: (InternalError) cannot drop table tbl_1 because > other objects depend on it > DETAIL: view view_1 depends on table tbl_1

Re: [sqlalchemy] Failed to drop view when working with Postgresql in alembic migration script

2012-11-01 Thread junepeach
Yes, it is true for the view, but I also got below error when a view references tables: 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 to

Re: [sqlalchemy] Failed to drop view when working with Postgresql in alembic migration script

2012-11-01 Thread Michael Bayer
On Nov 1, 2012, at 12:15 PM, junepeach wrote: > When I removed all of op.execute('drop view xxx') and op.execute('create view > xxx as ...') scripts, all of commands work fine even in Postgresql. I think > this is because I have put clear relationship in table class in my schema > module: > >

Re: [sqlalchemy] Failed to drop view when working with Postgresql in alembic migration script

2012-11-01 Thread junepeach
Thank you, I will test your above idea. By the way, I am new to both Alembic and Sqlalchemy. Right now our database has around 90 tables, and 12 views (could be more), and we would like to support as many databases as we can. Postgresql works fine with both 'alembic revision --autogenerate' an

Re: [sqlalchemy] Failed to drop view when working with Postgresql in alembic migration script

2012-11-01 Thread Michael Bayer
A "cascade" feature requires reading the database. For Alembic, reading the database occurs in the "autogenerate" feature, which will render the "drop_table()" instructions in the correct order in your migration script. if not using autogenerate, the reading has to be done elsewhere. This is

Re: [sqlalchemy] Failed to drop view when working with Postgresql in alembic migration script

2012-11-01 Thread junepeach
Thanks for the suggestion.I solved the problem by putting the dependents' drop command first in function def downgrade(): For example, if A refers to/uses B, I need to drop B first, then drop A. I don't know other better way. Will Alembic support 'cascade' in future version? -- You received t