forked from galaxyproject/galaxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Preserve manage_db.sh, but do not hide alembic
- Preserves usage of legacy script while not hiding the Alembic script. (see manage_db.sh and run_alembic.sh) - Adds documentation (see top of script files) - Includes misc. relevant refactorings - Includes unit tests for testing legacy script handling
- Loading branch information
Showing
11 changed files
with
271 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/bin/sh | ||
|
||
####### | ||
# The purpose of this script is to preserve the legacy interface provided by | ||
# manage_db.sh, which was a thin wrapper around SQLAlchemy Migrate. Unless you | ||
# need to use the legacy interface, to manage migrations of the "galaxy" and | ||
# "install" databases, you are encouraged to use run_alembic.sh directly and | ||
# take advantage of Alembic's command line options. | ||
# | ||
# Use this script to upgrade or downgrade your database. | ||
# Database options: galaxy (default), install, tool_shed | ||
# To pass a galaxy config file, you may use `-c|--config|--config-file your-config-file` | ||
|
||
# To upgrade or downgrade to some version X: | ||
# sh manage_db.sh [upgrade|downgrade] --version=X [tool_shed|install|galaxy] | ||
# | ||
# You may also skip the version argument when upgrading, in which case the database | ||
# will be upgraded to the latest version. | ||
# | ||
# Example 1: upgrade "galaxy" database to version "abc123" using default config: | ||
# sh manage_db.sh upgrade --version=xyz567 | ||
# | ||
# Example 2: downgrade "install" database to version "xyz789" passing config file "mygalaxy.yml": | ||
# sh manage_db.sh downgrade --version=abc123 -c mygalaxy.yml install | ||
# | ||
# Example 3: upgrade "galaxy" database to latest version using defualt config: | ||
# sh manage_db.sh upgrade | ||
# | ||
# (Note: Tool Shed migrations use the legacy migrations system, so we check the | ||
# last argument (the database) to invoke the appropriate script. Therefore, if | ||
# you don't specify the database (galaxy is used by default) and pass a config | ||
# file, your config file should not be named `tool_shed`.) | ||
####### | ||
|
||
ALEMBIC_CONFIG='lib/galaxy/model/migrations/alembic.ini' | ||
|
||
cd `dirname $0` | ||
|
||
. ./scripts/common_startup_functions.sh | ||
|
||
setup_python | ||
|
||
for i; do :; done | ||
if [ "$i" == "tool_shed" ]; then | ||
python ./scripts/migrate_toolshed_db.py $@ tool_shed | ||
else | ||
find lib/galaxy/model/migrations/alembic -name '*.pyc' -delete | ||
python ./scripts/manage_db_adapter.py --alembic-config "$ALEMBIC_CONFIG" $@ | ||
fi |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
""" | ||
This script is intended to be invoked by the legacy manage_db.sh script. | ||
It translates the arguments supplied to manage_db.sh into the format used | ||
by migrate_db.py. | ||
INPUT: | OUTPUT: | ||
---------------------------------------------------------- | ||
upgrade --version=foo | upgrade foo | ||
upgrade --version foo | upgrade foo | ||
upgrade | upgrade gxy@head | ||
upgrade install | upgrade tsi@head | ||
upgrade --version=bar install | upgrade bar | ||
upgrade -c path-to-galaxy.yml | upgrade --galaxy-config path-to-galaxy.yml gxy@head | ||
The converted sys.argv will include `-c path-to-alembic.ini`. | ||
The optional `-c` argument name is renamed to `--galaxy-config`. | ||
""" | ||
|
||
import os | ||
import sys | ||
|
||
import alembic.config | ||
|
||
sys.path.insert(1, os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, 'lib'))) | ||
|
||
from galaxy.model.migrations.scripts import ( | ||
add_db_urls_to_command_arguments, | ||
LegacyScripts, | ||
) | ||
|
||
|
||
def run(): | ||
ls = LegacyScripts() | ||
target_database = ls.pop_database_argument(sys.argv) | ||
ls.rename_config_argument(sys.argv) | ||
ls.rename_alembic_config_argument(sys.argv) | ||
ls.convert_version_argument(sys.argv, target_database) | ||
add_db_urls_to_command_arguments(sys.argv, os.getcwd()) | ||
alembic.config.main() | ||
|
||
|
||
if __name__ == '__main__': | ||
run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.