Switch to unified view

a/pyforge/flyway/runner.py b/pyforge/flyway/runner.py
...
...
30
        log.info('Migrate %r', step)
30
        log.info('Migrate %r', step)
31
        if dry_run: continue
31
        if dry_run: continue
32
        step.apply(info.versions)
32
        step.apply(info.versions)
33
        info.m.save()
33
        info.m.save()
34
34
35
def show_status(datastore):
36
    # Get the migration status of the db
37
    session = MigrationInfo.__mongometa__.session
38
    session.bind = datastore
39
    info = MigrationInfo.m.get()
40
    if info is None:
41
        info = MigrationInfo.make({})
42
    for k,v in info.versions.iteritems():
43
        log.info('%s=%s', k, v)
44
45
def set_status(datastore, target_versions):
46
    # Get the migration status of the db
47
    session = MigrationInfo.__mongometa__.session
48
    session.bind = datastore
49
    info = MigrationInfo.m.get()
50
    if info is None:
51
        info = MigrationInfo.make({})
52
    latest_versions = Migration.latest_versions()
53
    for k,v in target_versions.iteritems():
54
        cur = info.versions.get(k, -1)
55
        islatest = ' (LATEST)' if v == latest_versions[k] else ''
56
        log.info('FORCE %s=%s%s (current=%s)', k, v, islatest, cur)
57
    info.versions.update(target_versions)
58
    info.m.save()
59
35
def plan_migration(session, ormsession, info, target):
60
def plan_migration(session, ormsession, info, target):
36
    '''Return the optimal list of graph.MigrationSteps to run in order to
61
    '''Return the optimal list of graph.MigrationSteps to run in order to
37
    satisfy the target requirements'''
62
    satisfy the target requirements'''
38
    migrations = dict((k, v(session, ormsession))
63
    migrations = dict((k, v(session, ormsession))
39
                      for k,v in Migration.migrations_registry.iteritems())
64
                      for k,v in Migration.migrations_registry.iteritems())