Skip to content

Commit

Permalink
Update DB commands
Browse files Browse the repository at this point in the history
  • Loading branch information
tino097 committed Sep 10, 2018
1 parent 95fd8e5 commit bae6951
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
19 changes: 16 additions & 3 deletions ckan/cli/db.py
Expand Up @@ -31,8 +31,8 @@ def initdb():


@db.command(u'clean', short_help=u'Clean the database')
@click.help_option(u'-h', u'--help')
@click.confirmation_option(prompt=prompt_msg)
@click.help_option(u'-h', u'--help')
def cleandb():
u'''Cleaning the database'''
try:
Expand All @@ -44,12 +44,25 @@ def cleandb():


@db.command(u'upgrade', short_help=u'Upgrade the database')
@click.option(u'-v', u'--version', help='Migration version')
@click.help_option(u'-h', u'--help')
def updatedb():
def updatedb(version=None):
u'''Upgrading the database'''
try:
import ckan.model as model
model.repo.upgrade_db()
model.repo.upgrade_db(version)
except Exception as e:
print(e)
print(u'Upgrading DB: SUCCESS')


@db.command(u'version', short_help=u'Returns current version of data schema')
@click.help_option(u'-h', u'--help')
def version():
u'''Return current version'''
try:
from ckan.model import Session
print(Session.execute('select version from '
'migrate_version;').fetchall())
except Exception as e:
print(e)
1 change: 1 addition & 0 deletions ckan/cli/server.py
Expand Up @@ -8,6 +8,7 @@

from ckan.cli import load_config, click_config_option


@click.command(u'run', short_help=u'Start development server')
@click.help_option(u'-h', u'--help')
@click_config_option
Expand Down

0 comments on commit bae6951

Please sign in to comment.