+ self.assertEqual(list(migration.MigrationHistory.objects.all()), [])
+
+ def test_alter_column_null(self):
+ def null_ok():
+ from django.db import connection, transaction
+ # the DBAPI introspection module fails on postgres NULLs.
+ cursor = connection.cursor()
+ try:
+ cursor.execute("INSERT INTO southtest_spam (id, weight, expires, name) VALUES (100, 10.1, now(), NULL);")
+ except:
+ transaction.rollback()
+ return False
+ else:
+ cursor.execute("DELETE FROM southtest_spam")
+ transaction.commit()
+ return True
+
+ app = migration.get_app("fakeapp")
+ self.assertEqual(list(migration.MigrationHistory.objects.all()), [])
+
+ # by default name is NOT NULL
+ migration.migrate_app(app, target_name="0002", resolve_mode=None, fake=False, silent=True)
+ self.failIf(null_ok())
+
+ # after 0003, it should be NULL
+ migration.migrate_app(app, target_name="0003", resolve_mode=None, fake=False, silent=True)
+ self.assert_(null_ok())
+
+ # make sure it is NOT NULL again
+ migration.migrate_app(app, target_name="0002", resolve_mode=None, fake=False, silent=True)
+ self.failIf(null_ok(), 'name not null after migration')
+
+ # finish with no migrations, otherwise other tests fail...
+ migration.migrate_app(app, target_name="zero", resolve_mode=None, fake=False, silent=True)