
    Evg'&                     n    d dl Z d dlmZ d dlmZ ddlmZ  G d d          Z G d d	e          Z	d
 Z
dS )    N)get_migration_name_timestamp)atomic   )IrreversibleErrorc                   f    e Zd 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dd	ZddZddZd ZdS )	Migrationa  
    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.
    NTc                    || _         || _        t          | j        j                  | _        t          | j        j                  | _        t          | j        j                  | _        t          | j        j                  | _        d S N)name	app_labellist	__class__
operationsdependencies
run_beforereplaces)selfr   r   s      [/var/www/pixelcanvas.ch/venv/lib/python3.11/site-packages/django/db/migrations/migration.py__init__zMigration.__init__7   se    	"t~899 !<==t~899T^455    c                 l    t          |t                    o| j        |j        k    o| j        |j        k    S r
   )
isinstancer   r   r   )r   others     r   __eq__zMigration.__eq__@   s6    ui(( 2	UZ'2%/1	
r   c                 (    d| j         d| j        dS )Nz<Migration .>r   r   r   s    r   __repr__zMigration.__repr__G   s     &*nnndiii@@r   c                 $    | j         d| j        S Nr   r   r   s    r   __str__zMigration.__str__J   s    ...$))44r   c                 >    t          | j        d| j                  S r"   )hashr   r   r   s    r   __hash__zMigration.__hash__M   s    t~~~tyy9:::r   c                     |}|r|                                 }| j        D ]}|                    | j        |           |S )z
        Take a ProjectState and return a new one with the migration's
        operations applied to it. Preserve the original object state by
        default and return a mutated state from a copy.
        )cloner   state_forwardsr   )r   project_statepreserve	new_state	operations        r   mutate_statezMigration.mutate_stateP   sV     "	 	.%++--I 	@ 	@I$$T^Y????r   Fc                 2   | j         D ]}|r|j                            d           |j                            d|                                z             |j                            d           |j        s|j                            d           t          |j                  }|                                }|                    | j        |           |j	        p| j	        o|j	        du}|j
        sQ|rOt          |j        j                  5  |                    | j        |||           ddd           n# 1 swxY w Y   n|                    | j        |||           |r2|t          |j                  k    r|j                            d           |S )a  
        Take a project_state representing all migrations prior to this one
        and a schema_editor for a live database and apply the migration
        in a forwards order.

        Return the resulting project state for efficient reuse by following
        Migrations.
        ---- %s*-- THIS OPERATION CANNOT BE WRITTEN AS SQLFN
-- (no-op))r   collected_sqlappenddescribereduces_to_sqllenr(   r)   r   r   atomic_migration
connectionaliasdatabase_forwards)r   r*   schema_editorcollect_sqlr-   collected_sql_before	old_stateatomic_operations           r   applyzMigration.apply^   s
     !	A !	AI  	H+224888+227Y=O=O=Q=Q3QRRR+224888 / !/66D   '*=+F'G'G$%++--I$$T^]CCC(/  =	 0 =  !1 6F  M4:;;  //y-                 ++NM9m    A3s=;V7W7WWW+22<@@@s   D88D<	?D<	c                    g }|}| j         D ]{}|j        st          d|d| d          |                                }|                                }|                    | j        |           |                    d|||f           ||D ]b\  }}}	|r|j                            d           |j                            d|	                                z             |j                            d           |j
        s|j                            d           t          |j                  }
|j        p| j        o|j        du}|j        sQ|rOt          |j        j                  5  |                    | j        ||	|           d	d	d	           n# 1 swxY w Y   n|                    | j        ||	|           |r2|
t          |j                  k    r|j                            d
           d|S )a  
        Take a project_state representing all migrations prior to this one
        and a schema_editor for a live database and apply 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.
        z
Operation z in z is not reversibler   r0   r1   r2   FNr3   )r   
reversibler   r(   r)   r   insertr4   r5   r6   r7   r8   r   r9   r:   r;   database_backwards)r   r*   r=   r>   to_runr,   r-   r@   to_state
from_stater?   rA   s               r   unapplyzMigration.unapply   s    !	 	@ 	@I' ''>GiiN  
 "))I!))I$$T^Y???MM!iI>???? 06 	A 	A+Ix 	H+224888+227Y=O=O=Q=Q3QRRR+224888 / !/66D   '*=+F'G'G$(/  =	 0 =  !1 6F  M4:;;  00z8                 ,,NM:x    A3s=;V7W7WWW+22<@@@s   %FF	F	c                 2   | j         rdS d | j        D             }d |D             }|r%t          |          t          | j                  k    rdt                      z  S |d         }|dd         D ]%}| d| }t          |          d	k    r| d
} n|}&|S )z
        Suggest a name for the operations this migration might represent. Names
        are not guaranteed to be unique, but put some effort into the fallback
        name to avoid VCS conflicts if possible.
        initialc                     g | ]	}|j         
S  )migration_name_fragment).0ops     r   
<listcomp>z*Migration.suggest_name.<locals>.<listcomp>   s    NNN3NNNr   c                 >    g | ]}|t          j        d d|          S )z\W+_)resub)rP   r   s     r   rR   z*Migration.suggest_name.<locals>.<listcomp>   s+    QQQ4DQRVFC..QQQr   zauto_%sr   r   NrT   4   	_and_more)rL   r   r8   r   )r   raw_fragments	fragmentsr   fragmentnew_names         r   suggest_namezMigration.suggest_name   s     < 	9NNdoNNNQQ=QQQ	 	>C	NNc$/.B.BBB;====|!!"" 	 	H++++H8}}r!!)))DDr   )T)F)__name__
__module____qualname____doc__r   r   r   r   rL   r   r   r   r    r#   r&   r.   rB   rJ   r]   rN   r   r   r   r   	   s         $ J L
 J
 H G F6 6 6
 
 
A A A5 5 5; ; ;   + + + +Z; ; ; ;z    r   r   c                       e Zd ZdZd ZdS )SwappableTuplez
    Subclass of tuple so Django can tell this was originally a swappable
    dependency when it reads the migration file.
    c                 J    t                               | |          }||_        |S r
   )tuple__new__setting)clsvaluerg   r   s       r   rf   zSwappableTuple.__new__   s!    }}S%((r   N)r^   r_   r`   ra   rf   rN   r   r   rc   rc      s-         
    r   rc   c                 Z    t          |                     dd          d         df|           S )z'Turn a setting value into a dependency.r   r   r   	__first__)rc   split)ri   s    r   swappable_dependencyrm      s*    5;;sA..q1;?GGGr   )rU   django.db.migrations.utilsr   django.db.transactionr   
exceptionsr   r   re   rc   rm   rN   r   r   <module>rq      s    				 C C C C C C ( ( ( ( ( ( ) ) ) ) ) )U U U U U U U Up	 	 	 	 	U 	 	 	H H H H Hr   