﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
23406	Allow migrations to be loaded from .pyc files (e.g. in a frozen environment)	Daniel Menzel	Dan Watson	"
== Description ==

When only '''.pyc''' files are available, for example in a frozen environment after running ''cx_Freeze'' or similar tools, migrations no longer work: the migrate command does not find any migrations to apply, and produces the following output:

{{{
Operations to perform:
  Synchronize unmigrated apps: <some apps that really have no migrations>
  Apply all migrations: (none)
Synchronizing apps without migrations:
  Creating tables...
    Creating table <some tables>
  Installing custom SQL...
  Installing indexes...
Running migrations:
  No migrations to apply.
  Your models have changes that are not yet reflected in a migration, and so won't be applied.
  Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.
}}}

Subsequent operations then fail because the database is unmigrated.

The typical content of a frozen migrations folder looks like this:

{{{
django
  contrib
    contenttypes
      migrations
        __init__.pyc
        0001_initial.pyc
}}}


== Analysis ==

Due to issue [https://code.djangoproject.com/ticket/23237], there was a change in django.db.migrations.loader ([https://code.djangoproject.com/changeset/267630ad50c69ebfe594de37a0636264aa5be7d6]): Previously, migrations were found if they had a '''.py''', '''.pyc''', or '''.pyo''' extension. Now only migrations with '''.py''' extensions are found.

Perhaps it would be possible to add a check if Django is running in a frozen environment:

{{{
if hasattr(sys, 'frozen'):
    extensions = ('.py', '.pyc')
else:
    extensions = ('.py', )
...
if name.endswith(extensions):
    ...
}}}

or make the list of allowed extensions configurable by the user."	New feature	closed	Migrations	1.7	Normal	fixed	migrations, .pyc, frozen, cx_Freeze	Andrew Godwin Dan Watson Carlton Gibson	Ready for checkin	1	0	0	0	0	0
