ó
i4Vdc           @  s   d  d l  m Z d  d l m Z d  d l m Z d d l m Z e d e f d „  ƒ  Yƒ Z	 d e
 f d	 „  ƒ  YZ d
 „  Z d S(   iÿÿÿÿ(   t   unicode_literals(   t   atomic(   t   python_2_unicode_compatiblei   (   t   IrreversibleErrort	   Migrationc           B  s†   e  Z d  Z g  Z g  Z g  Z g  Z d
 Z d „  Z	 d „  Z
 d „  Z d „  Z d „  Z d „  Z e d „ Z e d „ Z e d	 „ Z RS(   uŽ  
    The base class for all migrations.

    Migration files will import this from django.db.migrations.Migration
    and subclass it as a class called Migration. It will have one or more
    of the following attributes:

     - operations: A list of Operation instances, probably from django.db.migrations.operations
     - dependencies: A list of tuples of (app_path, migration_name)
     - run_before: A list of tuples of (app_path, migration_name)
     - replaces: A list of migration_names

    Note that all migrations come out of migrations and into the Loader or
    Graph as instances, having been initialized with their app label and name.
    c         C  sj   | |  _  | |  _ t |  j j ƒ |  _ t |  j j ƒ |  _ t |  j j ƒ |  _ t |  j j ƒ |  _ d  S(   N(   t   namet	   app_labelt   listt	   __class__t
   operationst   dependenciest
   run_beforet   replaces(   t   selfR   R   (    (    sl   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/db/migrations/migration.pyt   __init__3   s    		c         C  s5   t  | t ƒ s t S|  j | j k o4 |  j | j k S(   N(   t
   isinstanceR   t   FalseR   R   (   R   t   other(    (    sl   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/db/migrations/migration.pyt   __eq__<   s    c         C  s   |  | k S(   N(    (   R   R   (    (    sl   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/db/migrations/migration.pyt   __ne__A   s    c         C  s   d |  j  |  j f S(   Nu   <Migration %s.%s>(   R   R   (   R   (    (    sl   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/db/migrations/migration.pyt   __repr__D   s    c         C  s   d |  j  |  j f S(   Nu   %s.%s(   R   R   (   R   (    (    sl   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/db/migrations/migration.pyt   __str__G   s    c         C  s   t  d |  j |  j f ƒ S(   Nu   %s.%s(   t   hashR   R   (   R   (    (    sl   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/db/migrations/migration.pyt   __hash__J   s    c         C  sF   | } | r | j  ƒ  } n  x$ |  j D] } | j |  j | ƒ q% W| S(   u×   
        Takes a ProjectState and returns a new one with the migration's
        operations applied to it. Preserves the original object state by
        default and will return a mutated state from a copy.
        (   t   cloneR	   t   state_forwardsR   (   R   t   project_statet   preservet	   new_statet	   operation(    (    sl   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/db/migrations/migration.pyt   mutate_stateM   s    c      
   C  s  x|  j  D]ú } | r~ | j j d ƒ | j sB | j j d ƒ n  | j j d | j ƒ  ƒ | j j d ƒ | j s~ q
 q~ n  | j ƒ  } | j |  j | ƒ | j j	 j
 rë | j rë t | j j ƒ  | j |  j | | | ƒ Wd QXq
 | j |  j | | | ƒ q
 W| S(   u  
        Takes a project_state representing all migrations prior to this one
        and a schema_editor for a live database and applies the migration
        in a forwards order.

        Returns the resulting project state for efficient re-use by following
        Migrations.
        u   --uB   -- MIGRATION NOW PERFORMS OPERATION THAT CANNOT BE WRITTEN AS SQL:u   -- %sN(   R	   t   collected_sqlt   appendt   reduces_to_sqlt   describeR   R   R   t
   connectiont   featurest   can_rollback_ddlR   t   aliast   database_forwards(   R   R   t   schema_editort   collect_sqlR   t	   old_state(    (    sl   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/db/migrations/migration.pyt   apply[   s"    			
		"c   
   
   C  sy  g  } | } xw |  j  D]l } | j s> t d | |  f ƒ ‚ n  | j ƒ  } | j ƒ  } | j |  j | ƒ | j d | | | f ƒ q Wxì | D]ä \ } } }	 | r
| j j d ƒ | j	 sÎ | j j d ƒ n  | j j d | j
 ƒ  ƒ | j j d ƒ | j	 s
q q
n  | j j j rX| j rXt | j j ƒ  | j |  j | |	 | ƒ Wd QXq | j |  j | |	 | ƒ q W| S(   uø  
        Takes a project_state representing all migrations prior to this one
        and a schema_editor for a live database and applies the migration
        in a reverse order.

        The backwards migration process consists of two phases:

        1. The intermediate states from right before the first until right
           after the last operation inside this migration are preserved.
        2. The operations are applied in reverse order using the states
           recorded in step 1.
        u$   Operation %s in %s is not reversiblei    u   --uB   -- MIGRATION NOW PERFORMS OPERATION THAT CANNOT BE WRITTEN AS SQL:u   -- %sN(   R	   t
   reversibleR   R   R   R   t   insertR   R    R!   R"   R#   R$   R%   R   R&   t   database_backwards(
   R   R   R(   R)   t   to_runR   R   R*   t   to_statet
   from_state(    (    sl   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/db/migrations/migration.pyt   unapply~   s0    			
		"N(   t   __name__t
   __module__t   __doc__R	   R
   R   R   t   Nonet   initialR   R   R   R   R   R   t   TrueR   R   R+   R2   (    (    (    sl   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/db/migrations/migration.pyR   	   s   							#t   SwappableTuplec           B  s   e  Z d  Z d „  Z RS(   u   
    Subclass of tuple so Django can tell this was originally a swappable
    dependency when it reads the migration file.
    c         C  s   t  j |  | ƒ } | | _ | S(   N(   t   tuplet   __new__t   setting(   t   clst   valueR<   R   (    (    sl   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/db/migrations/migration.pyR;   ¶   s    	(   R3   R4   R5   R;   (    (    (    sl   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/db/migrations/migration.pyR9   °   s   c         C  s#   t  |  j d d ƒ d d f |  ƒ S(   u2   
    Turns a setting value into a dependency.
    u   .i   i    u	   __first__(   R9   t   split(   R>   (    (    sl   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/db/migrations/migration.pyt   swappable_dependency¼   s    N(   t
   __future__R    t   django.db.transactionR   t   django.utils.encodingR   t
   exceptionsR   t   objectR   R:   R9   R@   (    (    (    sl   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/db/migrations/migration.pyt   <module>   s   ¦