1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

First pass on squashmigrations command; files are right, execution not.

This commit is contained in:
Andrew Godwin
2013-10-16 12:00:07 +01:00
parent 42f8666f6a
commit 763ac8b642
4 changed files with 127 additions and 4 deletions

View File

@@ -26,6 +26,7 @@ class MigrationWriter(object):
"""
items = {
"dependencies": repr(self.migration.dependencies),
"replaces_str": "",
}
imports = set()
# Deconstruct operations
@@ -49,6 +50,9 @@ class MigrationWriter(object):
items["imports"] = ""
else:
items["imports"] = "\n".join(imports) + "\n"
# If there's a replaces, make a string for it
if self.migration.replaces:
items['replaces_str'] = "\n replaces = %s\n" % repr(self.migration.replaces)
return (MIGRATION_TEMPLATE % items).encode("utf8")
@property
@@ -186,7 +190,7 @@ from django.db import models, migrations
%(imports)s
class Migration(migrations.Migration):
%(replaces_str)s
dependencies = %(dependencies)s
operations = %(operations)s