Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F7124022
D7910.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Subscribers
None
D7910.diff
View Options
diff --git a/swh/core/cli/db.py b/swh/core/cli/db.py
--- a/swh/core/cli/db.py
+++ b/swh/core/cli/db.py
@@ -256,20 +256,24 @@
default=False,
show_default=True,
)
+@click.option("--module-config-key", help="Module config key to lookup.", default=None)
@click.pass_context
-def db_version(ctx, module, show_all):
+def db_version(ctx, module, show_all, module_config_key=None):
"""Print the database version for the Software Heritage.
Example::
swh db version -d swh-test
+ swh db version scheduler
+ swh db version scrubber --module-config-key=scrubber_db
"""
from swh.core.db.db_utils import get_database_info, import_swhmodule
- # use the db cnx from the config file; the expected config entry is the
- # given module name
- cfg = ctx.obj["config"].get(module, {})
+ # use the db cnx from the config file; the expected config entry is either the given
+ # module_config_key or defaulting to the module name (if module_config_key is not
+ # provided)
+ cfg = ctx.obj["config"].get(module_config_key or module, {})
dbname = get_dburl_from_config(cfg)
if not dbname:
@@ -328,14 +332,18 @@
help="Do not ask questions (use default answer to all questions)",
default=True,
)
+@click.option(
+ "--module-config-key", help="Module configuration key to lookup.", default=None
+)
@click.pass_context
-def db_upgrade(ctx, module, to_version, interactive):
+def db_upgrade(ctx, module, to_version, interactive, module_config_key):
"""Upgrade the database for given module (to a given version if specified).
Examples::
swh db upgrade storage
swh db upgrade scheduler --to-version=10
+ swh db upgrade scrubber --to-version=10 --module-config-key=scrubber_db
"""
from swh.core.db.db_utils import (
@@ -345,9 +353,10 @@
swh_set_db_module,
)
- # use the db cnx from the config file; the expected config entry is the
- # given module name
- cfg = ctx.obj["config"].get(module, {})
+ # use the db cnx from the config file; the expected config entry is either the given
+ # module_config_key or defaulting to the module name (if module_config_key is not
+ # provided)
+ cfg = ctx.obj["config"].get(module_config_key or module, {})
dbname = get_dburl_from_config(cfg)
if not dbname:
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Dec 20 2024, 9:41 AM (11 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3216991
Attached To
D7910: Allow module to specify another config key than their module name
Event Timeline
Log In to Comment