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' and 'alembic 
upgrade head' commands, but failed with 'alembic downgrade -1' command, giving 
error:  
sqlalchemy.exc.InternalError: (InternalError) cannot drop view view_1 because 
other objects depend on it
DETAIL:  view view_2 depends on view view_1
HINT:  Use DROP ... CASCADE to drop the dependent objects too.
 'drop view view_1{}

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:

class Mytable(Base):
    __tablename__ = 'tbl_mytable
    id = Column(String(15), primary_key = True)
    name = Column(String(25))
    ...
    children = relationship('Yourtable')

but for view sql statement, I can just use pure sql code op.execute('...') to 
do both 'create' and 'drop' view work, no relationship involved. Surely it is 
true that we don't deal with any relationship between view and view, or between 
view and table in all of the database systems which should be very complicated. 

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