|
a/pyforge/flyway/migrate.py |
|
b/pyforge/flyway/migrate.py |
|
... |
|
... |
14 |
def __init__(cls, name, bases, dct):
|
14 |
def __init__(cls, name, bases, dct):
|
15 |
if cls._current_migrations_module is None: return
|
15 |
if cls._current_migrations_module is None: return
|
16 |
cls.migrations_registry[
|
16 |
cls.migrations_registry[
|
17 |
cls._current_migrations_module, cls.version] = cls
|
17 |
cls._current_migrations_module, cls.version] = cls
|
18 |
cls.module = cls._current_migrations_module
|
18 |
cls.module = cls._current_migrations_module
|
19 |
|
|
|
20 |
def get(cls, module, version):
|
|
|
21 |
'''Load a Migration class from the registry'''
|
|
|
22 |
return cls.migrations_registry[module, version]
|
|
|
23 |
|
19 |
|
24 |
def latest_versions(cls):
|
20 |
def latest_versions(cls):
|
25 |
result = {}
|
21 |
result = {}
|
26 |
for k,v in cls.migrations_registry:
|
22 |
for k,v in cls.migrations_registry:
|
27 |
if result.get(k, -1) < v:
|
23 |
if result.get(k, -1) < v:
|
|
... |
|
... |
49 |
return { self.module: self.version }
|
45 |
return { self.module: self.version }
|
50 |
|
46 |
|
51 |
def down_postcondition(self):
|
47 |
def down_postcondition(self):
|
52 |
return { self.module: self.version-1 }
|
48 |
return { self.module: self.version-1 }
|
53 |
|
49 |
|
54 |
def up(self):
|
50 |
def up(self): # pragma no cover
|
55 |
'''Upgrade to a new schema version'''
|
51 |
'''Upgrade to a new schema version'''
|
56 |
raise NotImplementedError, 'up'
|
52 |
raise NotImplementedError, 'up'
|
57 |
|
53 |
|
58 |
def down(self):
|
54 |
def down(self): # pragma no cover
|
59 |
'''Downgrade from this schema version (undo an 'up') '''
|
55 |
'''Downgrade from this schema version (undo an 'up') '''
|
60 |
raise NotImplementedError, 'down'
|
56 |
raise NotImplementedError, 'down'
|
61 |
|
57 |
|
62 |
def ensure_index(self, cls, fields, **kwargs):
|
58 |
def ensure_index(self, cls, fields, **kwargs):
|
63 |
'''Ensures that a particular index has been created in the DB'''
|
59 |
'''Ensures that a particular index has been created in the DB'''
|