Skip to content

Commit

Permalink
Added restoredb execution feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
tarequeh committed Apr 24, 2013
1 parent 046a7f0 commit 906ce36
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions django_extensions/management/commands/restoredb.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,15 @@ def do_sudo_postgresql_restore(self, infile):
from ... import settings

for extension_name in ['hstore', 'uuid-ossp']:
print 'Loading postgres extension %s for DB %s' % (extension_name, settings.DB_NAME)
print 'Postgres version %s specified' % settings.DB_VERSION
if settings.DB_VERSION == '9.0':
extension_path = os.path.join(settings.BACKUP_LOCATION, 'extensions', '%s.sql' % extension_name)
if os.path.exists(extension_path):
load_extension_cmd = 'sudo -u postgres psql %s < %s' % (settings.DB_NAME, extension_path)
print load_extension_cmd
os.system(load_extension_cmd)
else:
print 'Could not find extension file at %s' % extension_path
elif settings.DB_VERSION == '9.2':
load_extension_cmd = 'sudo -u postgres psql %s -c "create extension \\\"%s\\\""' % (settings.DB_NAME, extension_name)
print load_extension_cmd
os.system(load_extension_cmd)
2 changes: 1 addition & 1 deletion django_extensions/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
DB_HOST = settings.DATABASE_HOST
DB_PORT = settings.DATABASE_PORT

DB_VERSION = settings.DB_VERSION
DB_VERSION = getattr(settings, 'DB_VERSION', '')

if hasattr(settings, 'PROJECT_NAME'):
BACKUP_BASENAME = settings.PROJECT_NAME
Expand Down

0 comments on commit 906ce36

Please sign in to comment.