Skip to content

Commit

Permalink
Log migrations info in consistent way (#14158)
Browse files Browse the repository at this point in the history
same as #13458 but for `82b7c48c147f_remove_can_read_permission_on_config_.py` migration

This migration changes logging handlers
so each next migration is differently formatted when doing
airflow db reset. This commit fixes this behavior.

(cherry picked from commit e423e38)
  • Loading branch information
kaxil authored and ashb committed Mar 19, 2021
1 parent 05326e2 commit 76be86e
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
Create Date: 2021-02-04 12:45:58.138224
"""
import logging

from airflow.security import permissions
from airflow.www.app import create_app
Expand All @@ -36,6 +37,9 @@

def upgrade():
"""Remove can_read permission on config resource for User and Viewer role"""
log = logging.getLogger()
handlers = log.handlers[:]

appbuilder = create_app(config={'FAB_UPDATE_PERMS': False}).appbuilder
roles_to_modify = [role for role in appbuilder.sm.get_all_roles() if role.name in ["User", "Viewer"]]
can_read_on_config_perm = appbuilder.sm.find_permission_view_menu(
Expand All @@ -48,6 +52,8 @@ def upgrade():
):
appbuilder.sm.del_permission_role(role, can_read_on_config_perm)

log.handlers = handlers


def downgrade():
"""Add can_read permission on config resource for User and Viewer role"""
Expand Down

0 comments on commit 76be86e

Please sign in to comment.