所以我有2个架构,分别是Admin和Ruby,并且要进行迁移,我必须使用参数include_schemas=True
,但是我还有其他由Google云端SQL系统创建的架构,无法更改,但是flask DB upgrade
命令正在尝试从那里删除表,所以我的问题是我是否可以包含两个模式Ruby and Admin
或排除系统托管的模式。
我的烧瓶迁移配置:
migrate = Migrate(app, db, include_schemas=True, version_table_schema='Admin')
错误:
sqlalchemy.exc.InternalError: (pymysql.err.InternalError) (1227, 'Access denied; you need (at least one of) the SUPER privilege(s) for this operation')
[SQL:
DROP TABLE performance_schema.replication_applier_status_by_worker]
(Background on this error at: http://sqlalche.me/e/2j85)
请不要评论说要我给应用SUPER privilege
,因为我不希望它删除系统托管的架构。
答案 0 :(得分:0)
我通过在migrations/env.py
中创建新函数来修复它:
代码:
def include_object(object, name, type_, reflected, compare_to):
if type_ == 'table' and object.schema != 'Ruby' or object.schema != 'Admin':
return False
return True
并将此参数添加到context.configure
:
include_object=include_object