Skip to content

Commit

Permalink
Edit db wrapper scripts for consistency, add TS script
Browse files Browse the repository at this point in the history
  • Loading branch information
jdavcs committed Feb 8, 2023
1 parent e08e1aa commit 1dd0321
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 5 deletions.
2 changes: 1 addition & 1 deletion manage_db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions manage_toolshed_db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -11,4 +12,4 @@ cd "$(dirname "$0")" || exit

setup_python

python ./scripts/migrate_toolshed_db.py "$@" tool_shed
python ./scripts/toolshed_db.py "$@"
7 changes: 5 additions & 2 deletions scripts/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,18 @@

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:
parser = ArgumentParser(
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)

Expand Down
37 changes: 37 additions & 0 deletions scripts/toolshed_db.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 1dd0321

Please sign in to comment.