1. Ronny Pfannschmidt
  2. micromigrate

Commits

Ronny Pfannschmidt  committed 25c093f

utility for missing migrations

  • Participants
  • Parent commits b9dbdd8
  • Branches default

Comments (0)

Files changed (4)

File micromigrate/__init__.py

View file
  • Ignore whitespace
     'find_in_path',
 ]
 from .types import MigrationError
-from .util import apply_migrations, parse_migration
+from .util import apply_migrations, parse_migration, missing_migrations
 from .finder import find_in_path

File micromigrate/util.py

View file
  • Ignore whitespace
             return migrations.pop(name)
 
 
+def missing_migrations(db, migrations):
+    state = db.state() or {}
+    return verify_state(state, migrations)
+
 def apply_migrations(db, migrations):
-    state = db.state() or {}
-    missing_migrations = verify_state(state, migrations)
-
-    print(missing_migrations)
-    while missing_migrations:
+    missing = missing_migrations(db, migrations)
+    print(missing)
+    while missing:
         migration = pop_next_to_apply(
-                missing_migrations, state)
+                missing, state)
         db.apply(migration)
         state[migration.name] = migration.checksum
     real_state = db.state()

File testing/conftest.py

View file
  • Ignore whitespace
 @pytest.mark.tryfirst
 def pytest_runtest_makereport(item, __multicall__):
     report = __multicall__.execute()
-    conn = getattr(item, '_conn', None)
-    if conn is not None:
-        report.sections.append(('db', '\n'.join(conn.iterdump())))
+    dbname = getattr(item, '_dbname', None)
+    if dbname is not None:
+        from micromigrate.util import output_or_raise
+        
+        try:
+            report.sections.append(
+                ('db', output_or_raise('sqlite3', '.dump', dbname)))
+        except:
+            pass
     return report

File testing/test_miromigrate.py

View file
  • Ignore whitespace
     db.apply(migration)
     state = db.state()
     assert state == {'test': migration.checksum}
+    assert 0
 
 
 def test_migration_initial(db):