Skip to content

Commit

Permalink
do not abort on migrations which are not on the disk
Browse files Browse the repository at this point in the history
  • Loading branch information
piranha committed Mar 26, 2015
1 parent b0e3711 commit f27657e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Expand Up @@ -2,6 +2,11 @@
Nomad Changelog
=================

1.11
----

- Do not abort on migrations not on disk

1.10
----

Expand Down
10 changes: 7 additions & 3 deletions nomad/__init__.py
Expand Up @@ -11,7 +11,7 @@
from nomad.utils import abort, NomadError, NomadIniNotFound


__version__ = '1.10'
__version__ = '1.11'


GLOBAL = [
Expand Down Expand Up @@ -63,8 +63,12 @@ def list_(all=('a', False, 'show all migrations (default: only non-applied)'),
'''List migrations
'''
repo = opts['repo']
for m in repo.available:
if m in repo.applied:
all_migrations = repo.available + [m for m in repo.applied
if m not in repo.available]
for m in all_migrations:
if m not in repo.available:
print colored(m, 'red') + ' (not on disk)'
elif m in repo.applied:
if all:
cprint(m, 'magenta')
else:
Expand Down
8 changes: 3 additions & 5 deletions nomad/repo.py
Expand Up @@ -107,13 +107,9 @@ def __new__(cls, repo, name, **kwargs):
cls.SINGLETONS[key] = object.__new__(cls)
return cls.SINGLETONS[key]

def __init__(self, repo, name, force=False, applied=False):
def __init__(self, repo, name, applied=False):
self.repo = repo
self.name = name
if not op.exists(op.join(repo.path, name)) and not force:
raise NomadError(
'migration exists in database, but not found on the disk: %s'
% name)
self.conf = ConfigParser(
interpolation=ExtendedInterpolation(),
defaults={
Expand All @@ -124,7 +120,9 @@ def __init__(self, repo, name, force=False, applied=False):
self.conf.read([op.join(repo.path, name, 'migration.ini')])
deps = self.conf.get('nomad', 'dependencies', fallback='').split(',')
self._deps = [x.strip() for x in deps if x.strip()]

self.applied = applied
self.exists = op.exists(op.join(repo.path, name))

def __repr__(self):
return '<%s: %s>' % (type(self).__name__, str(self))
Expand Down

0 comments on commit f27657e

Please sign in to comment.