1
0
mirror of https://github.com/django/django.git synced 2025-10-27 15:46:10 +00:00

Turn SchemaEditor into a context manager

This commit is contained in:
Andrew Godwin
2013-05-18 11:06:30 +02:00
parent b31eea069c
commit ce5bd42259
2 changed files with 17 additions and 11 deletions

View File

@@ -37,10 +37,8 @@ class MigrationRecorder(object):
if self.Migration._meta.db_table in self.connection.introspection.get_table_list(self.connection.cursor()):
return
# Make the table
editor = self.connection.schema_editor()
editor.start()
editor.create_model(self.Migration)
editor.commit()
with self.connection.schema_editor() as editor:
editor.create_model(self.Migration)
def applied_migrations(self):
"""