diff --git a/manage_db.sh b/manage_db.sh index 10f1ad2500f3..9db984bad0ac 100755 --- a/manage_db.sh +++ b/manage_db.sh @@ -3,7 +3,7 @@ ####### # Use this script to manage Galaxy database schema migrations. # For help, run `sh manage_db.sh -h`. -# For detailed help, see documentation at lib/galaxy/model/migrations/README.md. +# For detailed help, see documentation at https://docs.galaxyproject.org/en/master/admin/db_migration.html ####### cd "$(dirname "$0")" || exit diff --git a/manage_toolshed_db.sh b/manage_toolshed_db.sh index 414fd47dfebf..634b5ed1d6db 100755 --- a/manage_toolshed_db.sh +++ b/manage_toolshed_db.sh @@ -2,7 +2,8 @@ ####### # Use this script to manage Tool Shed database migrations. -# NOTE: If your database is empty, use create_toolshed_db.sh instead. +# For help, run `sh manage_db.sh -h`. +# For detailed help, see documentation at https://docs.galaxyproject.org/en/master/admin/db_migration.html ####### cd "$(dirname "$0")" || exit @@ -11,4 +12,4 @@ cd "$(dirname "$0")" || exit setup_python -python ./scripts/migrate_toolshed_db.py "$@" tool_shed +python ./scripts/toolshed_db.py "$@" diff --git a/scripts/db.py b/scripts/db.py index f87b9b9d9d9d..f25d87e9d8fc 100644 --- a/scripts/db.py +++ b/scripts/db.py @@ -8,7 +8,10 @@ sys.path.insert(1, os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, "lib"))) -from galaxy.model.migrations.dbscript import ParserBuilder +from galaxy.model.migrations.dbscript import ( + CONFIG_FILE_ARG, + ParserBuilder, +) def main() -> None: @@ -16,7 +19,7 @@ def main() -> None: prog="manage_db.sh", description="Common database schema migration operations", ) - parser.add_argument("-c", "--galaxy-config", help="Alternate Galaxy configuration file", dest="config") + parser.add_argument("-c", f"{CONFIG_FILE_ARG}", help="Alternate Galaxy configuration file", dest="config") parser_builder = ParserBuilder(parser) diff --git a/scripts/toolshed_db.py b/scripts/toolshed_db.py new file mode 100644 index 000000000000..cd351c9c77f5 --- /dev/null +++ b/scripts/toolshed_db.py @@ -0,0 +1,37 @@ +""" +This script is intended to be invoked by the manage_toolshed_db.sh script. +""" + +import os +import sys +from argparse import ArgumentParser + +sys.path.insert(1, os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, "lib"))) + +from tool_shed.webapp.model.migrations.dbscript import ( + CONFIG_FILE_ARG, + ParserBuilder, +) + + +def main() -> None: + parser = ArgumentParser( + prog="manage_toolshed_db.sh", + description="Common database schema migration operations", + ) + parser.add_argument("-c", f"{CONFIG_FILE_ARG}", help="Alternate Tool Shed configuration file", dest="config") + + parser_builder = ParserBuilder(parser) + + parser_builder.add_upgrade_command() + parser_builder.add_downgrade_command() + parser_builder.add_version_command() + parser_builder.add_dbversion_command() + parser_builder.add_init_command() + + args = parser.parse_args() + args.func(args) + + +if __name__ == "__main__": + main()