Skip to content

Commit

Permalink
feat(fence-create): new migrate command to migrate the database (#694)
Browse files Browse the repository at this point in the history
* feat(fence-create): new migrate command to migrate the database

* chore(formatting): run black
  • Loading branch information
Avantol13 authored Sep 11, 2019
1 parent be6ef3c commit 4e80b35
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions bin/fence-create
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ from fence.scripting.fence_create import (
verify_bucket_access_group,
verify_user_registration,
force_update_google_link,
migrate_database,
)
from fence.settings import CONFIG_SEARCH_FOLDERS

Expand Down Expand Up @@ -305,6 +306,8 @@ def parse_arguments():
help="Google Project id that all users belong to",
)

subparsers.add_parser("migrate", help="Migrate the fence database")

return parser.parse_args()


Expand Down Expand Up @@ -491,6 +494,8 @@ def main():
notify_problem_users(
DB, args.emails, args.auth_ids, args.check_linking, args.google_project_id
)
elif args.action == "migrate":
migrate_database(DB)


if __name__ == "__main__":
Expand Down
6 changes: 6 additions & 0 deletions fence/scripting/fence_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
UserRefreshToken,
ServiceAccountToGoogleBucketAccessGroup,
query_for_user,
migrate,
)
from fence.scripting.google_monitor import email_users_without_access, validation_check
from fence.config import config
Expand Down Expand Up @@ -1347,3 +1348,8 @@ def notify_problem_users(db, emails, auth_ids, check_linking, google_project_id)
check_linking (bool): flag for if emails should be checked for linked google email
"""
email_users_without_access(db, auth_ids, emails, check_linking, google_project_id)


def migrate_database(db):
driver = SQLAlchemyDriver(db)
migrate(driver)

0 comments on commit 4e80b35

Please sign in to comment.