mirror of https://github.com/django/django.git
Only create the migration directory once per app
This commit is contained in:
parent
2d903929a7
commit
beefac8aae
|
@ -61,6 +61,7 @@ class Command(BaseCommand):
|
||||||
self.stdout.write("No changes detected")
|
self.stdout.write("No changes detected")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
directory_created = {}
|
||||||
for app_label, migrations in changes.items():
|
for app_label, migrations in changes.items():
|
||||||
self.stdout.write(self.style.MIGRATE_HEADING("Migrations for '%s':" % app_label) + "\n")
|
self.stdout.write(self.style.MIGRATE_HEADING("Migrations for '%s':" % app_label) + "\n")
|
||||||
for migration in migrations:
|
for migration in migrations:
|
||||||
|
@ -71,10 +72,13 @@ class Command(BaseCommand):
|
||||||
self.stdout.write(" - %s\n" % operation.describe())
|
self.stdout.write(" - %s\n" % operation.describe())
|
||||||
# Write it
|
# Write it
|
||||||
migrations_directory = os.path.dirname(writer.path)
|
migrations_directory = os.path.dirname(writer.path)
|
||||||
if not os.path.isdir(migrations_directory):
|
if not directory_created.get(app_label, False):
|
||||||
os.mkdir(migrations_directory)
|
if not os.path.isdir(migrations_directory):
|
||||||
init_path = os.path.join(migrations_directory, "__init__.py")
|
os.mkdir(migrations_directory)
|
||||||
if not os.path.isfile(init_path):
|
init_path = os.path.join(migrations_directory, "__init__.py")
|
||||||
open(init_path, "w").close()
|
if not os.path.isfile(init_path):
|
||||||
|
open(init_path, "w").close()
|
||||||
|
# We just do this once per app
|
||||||
|
directory_created[app_label] = True
|
||||||
with open(writer.path, "w") as fh:
|
with open(writer.path, "w") as fh:
|
||||||
fh.write(writer.as_string())
|
fh.write(writer.as_string())
|
||||||
|
|
Loading…
Reference in New Issue