-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add create/migrate scripts for tool shed
- Loading branch information
Showing
4 changed files
with
94 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/sh | ||
|
||
####### | ||
# Use this script to verify the state of the Tool Shed database. | ||
# If the database does not exist or is empty, it will be created | ||
# and initialized. | ||
# (For Galaxy and Tool Shed Install databases, use create_db.sh). | ||
####### | ||
|
||
cd "$(dirname "$0")" | ||
|
||
. ./scripts/common_startup_functions.sh | ||
|
||
setup_python | ||
|
||
python ./scripts/create_toolshed_db.py "$@" tool_shed |
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,18 @@ | ||
#!/bin/sh | ||
|
||
####### | ||
# Use this script to manage Tool Shed migrations. | ||
# (Use migrate_db.sh to manage Galaxy and Tool Shed Install migrations.) | ||
# | ||
# To downgrade to a specific version, use something like: | ||
# sh manage_toolshed_db.sh downgrade --version=3 tool_shed | ||
####### | ||
|
||
cd `dirname $0` | ||
|
||
. ./scripts/common_startup_functions.sh | ||
|
||
setup_python | ||
|
||
find lib/galaxy/model/migrate/versions -name '*.pyc' -delete | ||
python ./scripts/migrate_toolshed_db.py $@ |
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,29 @@ | ||
""" | ||
Creates the initial tool shed database schema using the settings defined in config/tool_shed.yml. | ||
Note: pass '-c /location/to/your_config.yml' for non-standard ini file locations. | ||
Note: if no database_connection is set in tool_shed.yml, the default, sqlite database will be constructed. | ||
This script is also wrapped by create_ts_db.sh. | ||
""" | ||
import logging | ||
import os.path | ||
import sys | ||
|
||
sys.path.insert(1, os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, 'lib'))) | ||
|
||
from galaxy.model.orm.scripts import get_config | ||
from tool_shed.webapp.model.migrate.check import create_or_verify_database as create_tool_shed_db | ||
|
||
logging.basicConfig(level=logging.DEBUG) | ||
log = logging.getLogger(__name__) | ||
|
||
|
||
def invoke_create(): | ||
config = get_config(sys.argv) | ||
create_tool_shed_db(config['db_url']) | ||
|
||
|
||
if __name__ == "__main__": | ||
invoke_create() |
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,31 @@ | ||
""" | ||
This script parses the Tool Shed config file for database connection | ||
and then delegates to sqlalchemy_migrate shell main function in | ||
migrate.versioning.shell. | ||
It is wrapped by migrate_toolshed_db.sh (see that file for usage). | ||
""" | ||
import logging | ||
import os.path | ||
import sys | ||
|
||
from migrate.versioning.shell import main | ||
|
||
sys.path.insert(1, os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, 'lib'))) | ||
|
||
from galaxy.model.orm.scripts import get_config | ||
|
||
logging.basicConfig(level=logging.DEBUG) | ||
log = logging.getLogger(__name__) | ||
|
||
|
||
def invoke_migrate_main(): | ||
# Migrate has its own args, so cannot use argparse | ||
config = get_config(sys.argv, use_argparse=False, cwd=os.getcwd()) | ||
db_url = config['db_url'] | ||
repo = config['repo'] | ||
|
||
main(repository=repo, url=db_url) | ||
|
||
|
||
if __name__ == "__main__": | ||
invoke_migrate_main() |