Commits

Ronny Pfannschmidt committed bfe64f0

track the initial migration correctly

  • Participants
  • Parent commits 94773a0

Comments (0)

Files changed (2)

File micromigrate.py

         else:
             assert items[0] != 'migration'
             assert meta[items[0]] is None
-            meta[items[0]] = tuple(items[1:])
+            meta[items[0]] = frozenset(items[1:])
     assert meta['name'] is not None
     return Migration(**meta)
 
             insert into micromigrate_migrations (name, checksum)
             values (:name, :checksum)""", migration._asdict())
     connection.execute(migration.sql)
-    connection.execute("""
-        update micromigrate_migrations
-            set completed = 1
-            where name = :name
-        """, migration._asdict())
+    if state:
+        c = connection.execute("""
+            update micromigrate_migrations
+                set completed = 1
+                where name = :name
+            """, migration._asdict())
+    else:
+        c = connection.execute("""
+            insert into micromigrate_migrations (name, checksum, completed)
+            values (:name, :checksum, 1)""", migration._asdict())
+    assert c.rowcount == 1
     state = state.copy()
     state[migration.name] = migration.checksum
     return state

File testing/test_miromigrate.py

     result = parse_migration("-- migration test\n"
                              "-- after fun")
     assert result.name == 'test'
-    assert result.after == ('fun',)
+    assert result.after == frozenset(('fun',))
 
 
 def test_migration_initial(plain_conn):