509318396
Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­
<!DOCTYPE html>
<html>
U
    S¤ðWù]  ã                   @   sî   d Z ddlmZ ddlZddlZddlT ddlmZ ddlmZ ddlmZ ddlm	Z	 dd	lm
Z
 dd
lmZ G dd„ deƒZdd„ ZG dd„ deƒZG dd„ deƒZdZG dd„ dedeƒƒZG dd„ deƒZG dd„ deƒZdd„ ZdS )aÝ
  
Lightweight schema migrations.

NOTE: Currently tested with SQLite and Postgresql. MySQL may be missing some
features.

Example Usage
-------------

Instantiate a migrator:

    # Postgres example:
    my_db = PostgresqlDatabase(...)
    migrator = PostgresqlMigrator(my_db)

    # SQLite example:
    my_db = SqliteDatabase('my_database.db')
    migrator = SqliteMigrator(my_db)

Then you will use the `migrate` function to run various `Operation`s which
are generated by the migrator:

    migrate(
        migrator.add_column('some_table', 'column_name', CharField(default=''))
    )

Migrations are not run inside a transaction, so if you wish the migration to
run in a transaction you will need to wrap the call to `migrate` in a
transaction block, e.g.:

    with my_db.transaction():
        migrate(...)

Supported Operations
--------------------

Add new field(s) to an existing model:

    # Create your field instances. For non-null fields you must specify a
    # default value.
    pubdate_field = DateTimeField(null=True)
    comment_field = TextField(default='')

    # Run the migration, specifying the database table, field name and field.
    migrate(
        migrator.add_column('comment_tbl', 'pub_date', pubdate_field),
        migrator.add_column('comment_tbl', 'comment', comment_field),
    )

Renaming a field:

    # Specify the table, original name of the column, and its new name.
    migrate(
        migrator.rename_column('story', 'pub_date', 'publish_date'),
        migrator.rename_column('story', 'mod_date', 'modified_date'),
    )

Dropping a field:

    migrate(
        migrator.drop_column('story', 'some_old_field'),
    )

Making a field nullable or not nullable:

    # Note that when making a field not null that field must not have any
    # NULL values present.
    migrate(
        # Make `pub_date` allow NULL values.
        migrator.drop_not_null('story', 'pub_date'),

        # Prevent `modified_date` from containing NULL values.
        migrator.add_not_null('story', 'modified_date'),
    )

Renaming a table:

    migrate(
        migrator.rename_table('story', 'stories_tbl'),
    )

Adding an index:

    # Specify the table, column names, and whether the index should be
    # UNIQUE or not.
    migrate(
        # Create an index on the `pub_date` column.
        migrator.add_index('story', ('pub_date',), False),

        # Create a multi-column index on the `pub_date` and `status` fields.
        migrator.add_index('story', ('pub_date', 'status'), False),

        # Create a unique index on the category and title fields.
        migrator.add_index('story', ('category_id', 'title'), True),
    )

Dropping an index:

    # Specify the index name.
    migrate(migrator.drop_index('story', 'story_pub_date_status'))
é    )Ú
namedtupleN)Ú*)ÚCommaClause)ÚEnclosedClause©ÚEntity)Ú
Expression)ÚNode)ÚOPc                   @   s8   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ ZdS )Ú	Operationz/Encapsulate a single schema altering operation.c                 O   s   || _ || _|| _|| _d S ©N)ÚmigratorÚmethodÚargsÚkwargs)Úselfr   r   r   r   © r   úD/opt/alt/python38/lib64/python3.8/site-packages/playhouse/migrate.pyÚ__init__u   s    zOperation.__init__c                 C   s   | j j ¡ }| |¡S r   )r   ÚdatabaseÚcompilerZ
parse_node)r   Únoder   r   r   r   Ú_parse_node{   s    zOperation._parse_nodec                 C   s"   |   |¡\}}| jj ||¡ d S r   )r   r   r   Úexecute_sql)r   r   ÚsqlZparamsr   r   r   Úexecute   s    zOperation.executec                 C   sP   t |tƒr|  |¡ n6t |tƒr*| ¡  n"t |ttfƒrL|D ]}|  |¡ q<d S r   )Ú
isinstancer	   r   r   ÚrunÚlistÚtupleÚ_handle_result)r   ÚresultÚitemr   r   r   r    ƒ   s    


zOperation._handle_resultc                 C   s2   | j  ¡ }d|d< |  t| j| jƒ| j|Ž¡ d S )NTÚgenerate)r   Úcopyr    Úgetattrr   r   r   )r   r   r   r   r   r   Œ   s
    
ÿzOperation.runN)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r    r   r   r   r   r   r   s   s   	r   c                    s   t  ˆ ¡‡ fdd„ƒ}|S )Nc                    s4   |  dd¡}|r ˆ | f|ž|ŽS t| ˆ jf|ž|ŽS )Nr#   F)Úpopr   r&   )r   r   r   r#   ©Úfnr   r   Úinner”   s    zoperation.<locals>.inner)Ú	functoolsÚwraps)r,   r-   r   r+   r   Ú	operation“   s    r0   c                   @   sÌ   e Zd ZdZdZdd„ Zedd„ ƒZedd„ ƒZ	edd	„ ƒZ
d
d„ Zedd„ ƒZedd„ ƒZedd„ ƒZed$dd„ƒZedd„ ƒZdd„ Zedd„ ƒZedd„ ƒZedd„ ƒZed%dd „ƒZed!d"„ ƒZd#S )&ÚSchemaMigratorFc                 C   s
   || _ d S r   )r   )r   r   r   r   r   r       s    zSchemaMigrator.__init__c                 C   s0   t |tƒrt|ƒS t |tƒr$t|ƒS t|ƒS d S r   )r   ZPostgresqlDatabaseÚPostgresqlMigratorZMySQLDatabaseÚMySQLMigratorÚSqliteMigrator)Úclsr   r   r   r   Úfrom_database£   s
    

zSchemaMigrator.from_databasec                 C   sJ   |j }t|ƒr|ƒ }ttdƒt|ƒtdƒtt|ƒtjt| 	|¡ƒdd�ƒS )NZUPDATEZSETT)Zflat)
ÚdefaultÚcallableÚClauseÚSQLr   r   r
   ZEQZParamZdb_value)r   ÚtableÚcolumn_nameÚfieldr7   r   r   r   Úapply_default¬   s    üüzSchemaMigrator.apply_defaultc                 C   sj   |j d }|_ | |_|_| j ¡  |¡}||_ tdƒt|ƒtdƒ|g}t|t	ƒrb| 
|  |¡¡ t|Ž S )NTúALTER TABLEz
ADD COLUMN)ÚnullÚnameÚ	db_columnr   r   Zfield_definitionr:   r   r   ÚForeignKeyFieldÚextendÚget_inline_fk_sqlr9   )r   r;   r<   r=   Z
field_nullZfield_clauseÚpartsr   r   r   Úalter_add_column¼   s    ü
zSchemaMigrator.alter_add_columnc                 C   s$   t dƒt|jjjƒtt|jjƒƒgS )NÚ
REFERENCES)r:   r   Ú	rel_modelÚ_metaÚdb_tabler   Úto_fieldrB   ©r   r=   r   r   r   rE   Ì   s    ýz SchemaMigrator.get_inline_fk_sqlc                 C   s   t ‚d S r   ©ÚNotImplementedError)r   r;   r<   r=   r   r   r   Úadd_foreign_key_constraintÓ   s    z)SchemaMigrator.add_foreign_key_constraintc                 C   sœ   |j s|jd krtd| ƒ‚t|tƒ}|r8|js8tdƒ‚|  |||¡g}|j sn| |  |||¡|  	||¡g¡ |r˜| j
r˜| |  |||jjj|jj¡¡ |S )Nz!%s is not null but has no defaultz'Foreign keys must specify a `to_field`.)r@   r7   Ú
ValueErrorr   rC   rL   rG   rD   r>   Úadd_not_nullÚexplicit_create_foreign_keyÚappendrP   rI   rJ   rK   rB   )r   r;   r<   r=   Úis_foreign_keyÚ
operationsr   r   r   Ú
add_column×   s*    


þ
üÿzSchemaMigrator.add_columnc                 C   s   t ‚d S r   rN   ©r   r;   r<   r   r   r   Údrop_foreign_key_constraintù   s    z*SchemaMigrator.drop_foreign_key_constraintTc                 C   sr   t dƒt|ƒt dƒt|ƒg}|r.| t dƒ¡ t|Ž }dd„ | j |¡D ƒ}||krj| jrj|  ||¡|gS |S d S )Nr?   zDROP COLUMNZCASCADEc                 S   s   g | ]
}|j ‘qS r   ©Úcolumn)Ú.0Zforeign_keyr   r   r   Ú
<listcomp>  s   ÿz.SchemaMigrator.drop_column.<locals>.<listcomp>)r:   r   rT   r9   r   Úget_foreign_keysÚexplicit_delete_foreign_keyrY   )r   r;   r<   ÚcascadeÚnodesZdrop_column_nodeZ
fk_columnsr   r   r   Údrop_columný   s     ü
þ
þzSchemaMigrator.drop_columnc                 C   s*   t tdƒt|ƒtdƒt|ƒtdƒt|ƒƒS )Nr?   zRENAME COLUMNÚTO©r9   r:   r   )r   r;   Úold_nameÚnew_namer   r   r   Úrename_column  s    úzSchemaMigrator.rename_columnc                 C   s   t dƒt|ƒt dƒt|ƒgS )Nr?   zALTER COLUMN)r:   r   ©r   r;   r[   r   r   r   Ú_alter_column  s
    üzSchemaMigrator._alter_columnc                 C   s"   |   ||¡}| tdƒ¡ t|Ž S )NzSET NOT NULL©ri   rT   r:   r9   ©r   r;   r[   ra   r   r   r   rR   "  s    zSchemaMigrator.add_not_nullc                 C   s"   |   ||¡}| tdƒ¡ t|Ž S )NzDROP NOT NULLrj   rk   r   r   r   Údrop_not_null(  s    zSchemaMigrator.drop_not_nullc                 C   s   t tdƒt|ƒtdƒt|ƒƒS )Nr?   z	RENAME TOrd   ©r   re   rf   r   r   r   Úrename_table.  s    üzSchemaMigrator.rename_tablec                 C   sL   | j  ¡ }|rdnd}tt|ƒt| ||¡ƒtdƒt|ƒtdd„ |D ƒŽ ƒS )NzCREATE UNIQUE INDEXzCREATE INDEXÚONc                 S   s   g | ]}t |ƒ‘qS r   r   ©r\   r[   r   r   r   r]   ?  s     z,SchemaMigrator.add_index.<locals>.<listcomp>)r   r   r9   r:   r   Ú
index_namer   )r   r;   ÚcolumnsÚuniquer   Z	statementr   r   r   Ú	add_index6  s    
ûzSchemaMigrator.add_indexc                 C   s   t tdƒt|ƒƒS )Nú
DROP INDEXrd   ©r   r;   rq   r   r   r   Ú
drop_indexA  s    þzSchemaMigrator.drop_indexN)T)F)r&   r'   r(   rS   r_   r   Úclassmethodr6   r0   r>   rG   rE   rP   rW   rY   rb   rg   ri   rR   rl   rn   rt   rw   r   r   r   r   r1   œ   s>   




!

	



r1   c                       s(   e Zd Zdd„ Ze‡ fdd„ƒZ‡  ZS )r2   c                 C   s&   d}| j  || ¡}dd„ | ¡ D ƒS )Nai  
            SELECT pg_attribute.attname
            FROM pg_index, pg_class, pg_attribute
            WHERE
                pg_class.oid = '%s'::regclass AND
                indrelid = pg_class.oid AND
                pg_attribute.attrelid = pg_class.oid AND
                pg_attribute.attnum = any(pg_index.indkey) AND
                indisprimary;
        c                 S   s   g | ]}|d  ‘qS ©r   r   )r\   Úrowr   r   r   r]   U  s     z;PostgresqlMigrator._primary_key_columns.<locals>.<listcomp>)r   r   Úfetchall)r   ZtblÚqueryÚcursorr   r   r   Ú_primary_key_columnsI  s    
z'PostgresqlMigrator._primary_key_columnsc           
         sŒ   |   |¡}tt| ƒ}|j||dd�g}t|ƒdkrˆd||d f }d}| j ||f¡}t| ¡ ƒrˆd||d f }	| 	|j||	dd�¡ |S )NT)r#   é   z	%s_%s_seqr   z�
                SELECT 1
                FROM information_schema.sequences
                WHERE LOWER(sequence_name) = LOWER(%s)
            )
r~   Úsuperr2   rn   Úlenr   r   ÚboolÚfetchonerT   )
r   re   rf   Zpk_namesZParentClassrV   Zseq_namer|   r}   Znew_seq_name©Ú	__class__r   r   rn   W  s     

ÿ  ÿzPostgresqlMigrator.rename_table)r&   r'   r(   r~   r0   rn   Ú__classcell__r   r   r„   r   r2   H  s   r2   )rA   Ú
definitionr@   Úpkr7   Úextrac                   @   s:   e Zd Zedd„ ƒZedd„ ƒZedd„ ƒZd
dd	„ZdS )ÚMySQLColumnc                 C   s
   | j dkS )NZPRI©rˆ   ©r   r   r   r   Úis_pkr  s    zMySQLColumn.is_pkc                 C   s
   | j dkS )NZUNIr‹   rŒ   r   r   r   Ú	is_uniquev  s    zMySQLColumn.is_uniquec                 C   s
   | j dkS )NZYES)r@   rŒ   r   r   r   Úis_nullz  s    zMySQLColumn.is_nullNc                 C   s–   |d kr| j }|d kr| j}t|ƒt| jƒg}| jrB| tdƒ¡ |rV| tdƒ¡ n| tdƒ¡ | jrx| tdƒ¡ | jrŽ| t| jƒ¡ t	|Ž S )NZUNIQUEZNULLúNOT NULLzPRIMARY KEY)
r�   rA   r   r:   r‡   rŽ   rT   r�   r‰   r9   )r   r<   r�   rF   r   r   r   r   ~  s"    þzMySQLColumn.sql)NN)r&   r'   r(   Úpropertyr�   rŽ   r�   r   r   r   r   r   rŠ   q  s   


rŠ   Z_Columnc                   @   s€   e Zd ZdZdZedd„ ƒZdd„ Zedd„ ƒZdd	„ Z	ed
d„ ƒZ
dd„ Zedd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZdS )r3   Tc                 C   s   t tdƒt|ƒtdƒt|ƒƒS )NzRENAME TABLErc   rd   rm   r   r   r   rn   —  s    üzMySQLMigrator.rename_tablec                 C   s@   | j  d| ¡}| ¡ }|D ]}t|Ž }|j|kr|  S qdS )NzDESCRIBE %s;F)r   r   r{   rŠ   rA   )r   r;   r<   r}   Zrowsrz   r[   r   r   r   Ú_get_column_definitionŸ  s    

z$MySQLMigrator._get_column_definitionc                 C   sR   d|||f }t tdƒt|ƒtdƒt|ƒtdƒtt|ƒƒtdƒt|ƒtt|ƒƒƒ	S )Nzfk_%s_%s_refs_%sr?   zADD CONSTRAINTzFOREIGN KEYrH   )r9   r:   r   r   )r   r;   r<   ZrelZ
rel_columnZ
constraintr   r   r   rP   ¨  s    

÷z(MySQLMigrator.add_foreign_key_constraintc                 C   s6   | j  d||f¡}| ¡ }|s.td||f ƒ‚|d S )Nz‰SELECT constraint_name FROM information_schema.key_column_usage WHERE table_schema = DATABASE() AND table_name = %s AND column_name = %s;z=Unable to find foreign key constraint for "%s" on table "%s".r   )r   r   rƒ   ÚAttributeError)r   r;   r<   r}   r!   r   r   r   Úget_foreign_key_constraint·  s    úÿÿz(MySQLMigrator.get_foreign_key_constraintc              	   C   s&   t tdƒt|ƒtdƒt|  ||¡ƒƒS )Nr?   zDROP FOREIGN KEY)r9   r:   r   r”   rX   r   r   r   rY   Æ  s    üz)MySQLMigrator.drop_foreign_key_constraintc                 C   s   g S r   r   rM   r   r   r   rE   Î  s    zMySQLMigrator.get_inline_fk_sqlc                 C   s.   |   ||¡}ttdƒt|ƒtdƒ|jdd�ƒS )Nr?   ÚMODIFYF©r�   )r’   r9   r:   r   r   rh   r   r   r   rR   Ñ  s    
üzMySQLMigrator.add_not_nullc                 C   s<   |   ||¡}|jrtdƒ‚ttdƒt|ƒtdƒ|jdd�ƒS )NzPrimary keys can not be nullr?   r•   Tr–   )r’   r�   rQ   r9   r:   r   r   rh   r   r   r   rl   Ú  s    
üzMySQLMigrator.drop_not_nullc           	      C   sŒ   t dd„ | j |¡D ƒƒ}||k}|  ||¡}ttdƒt|ƒtdƒt|ƒ|j|d�ƒ}|r„|| }|  ||¡||  	|||j
|j¡gS |S d S )Nc                 s   s   | ]}|j |fV  qd S r   rZ   )r\   Zfkr   r   r   Ú	<genexpr>ç  s   ÿz.MySQLMigrator.rename_column.<locals>.<genexpr>r?   ZCHANGE)r<   )Údictr   r^   r’   r9   r:   r   r   rY   rP   Z
dest_tableZdest_column)	r   r;   re   rf   Z
fk_objectsrU   r[   Zrename_clauseZfk_metadatar   r   r   rg   å  s0    
þ
û
üý
zMySQLMigrator.rename_columnc                 C   s   t tdƒt|ƒtdƒt|ƒƒS )Nru   ro   rd   rv   r   r   r   rw     s    üzMySQLMigrator.drop_indexN)r&   r'   r(   rS   r_   r0   rn   r’   rP   r”   rY   rE   rR   rl   rg   rw   r   r   r   r   r3   “  s&   
	





r3   c                   @   s’   e Zd ZdZe d¡Ze d¡Ze d¡Ze dej	¡Z
dd„ Zdd	„ Zed
d„ ƒZdd„ Zeddd„ƒZedd„ ƒZedd„ ƒZedd„ ƒZdS )r4   zˆ
    SQLite supports a subset of ALTER TABLE queries, view the docs for the
    full details http://sqlite.org/lang_altertable.html
    z(.+?)\((.+)\)z(?:[^,(]|\([^)]*\))+z["`']?([\w]+)z FOREIGN KEY\s+\("?([\w]+)"?\)\s+c                 C   s    | j  d| ¡}dd„ |jD ƒS )Nzselect * from "%s" limit 1c                 S   s   g | ]}|d  ‘qS ry   r   )r\   r"   r   r   r   r]     s     z4SqliteMigrator._get_column_names.<locals>.<listcomp>)r   r   Zdescription©r   r;   Úresr   r   r   Ú_get_column_names  s    z SqliteMigrator._get_column_namesc                 C   s   | j  dd| ¡ g¡}| ¡ S )NzBselect name, sql from sqlite_master where type=? and LOWER(name)=?r;   )r   r   Úlowerrƒ   r™   r   r   r   Ú_get_create_table  s
    
ýz SqliteMigrator._get_create_tablec              	      s  t dd„ ˆj |¡D ƒƒ}| ¡ |kr6td||f ƒ‚ˆ |¡\}}ˆj |¡}ˆj |¡ t 	dd|¡}ˆj
 |¡ ¡ \}}ˆj |¡}	dd„ |	D ƒ}
g }g }g }|
D ]Ž}ˆj |¡ ¡ \}||k�r
|||ƒ}|�r6| |¡ | |¡ ˆj |¡ ¡ \}| |¡ q¨| |¡ | ¡  d¡s¨| |¡ | |¡ q¨tt||ƒƒ}| |¡‰ d	d
„ }ˆ �shdd
„ }nˆ |k�r€‡ ‡fdd
„}g }|D ]F}ˆj |¡}|d k	�r¼| ¡ d |k�r¼||ƒ}|�rˆ| |¡ �qˆ|d }t d| tj¡}| 	d| |¡}d |¡}ttdƒt|ƒƒtd| ¡ |f ƒg}ttdƒt|ƒtdd„ |D ƒŽ tdƒtdd„ |D ƒŽ tdƒt|ƒƒ}| |¡ | ttdƒt|ƒƒ¡ | ˆ  ||¡¡ t!dd
„ |ƒD ]R}||j"k�rÒ| t|j#ƒ¡ n.ˆ �r°ˆ $|j#|ˆ ¡}|d k	�r°| t|ƒ¡ �q°|S )Nc                 s   s   | ]}|j  ¡ V  qd S r   )rA   rœ   rp   r   r   r   r—      s   ÿz0SqliteMigrator._update_column.<locals>.<genexpr>z"Column "%s" does not exist on "%s"z\s+ú c                 S   s   g | ]}|  ¡ ‘qS r   ©Ústrip©r\   Úcolr   r   r   r]   8  s     z1SqliteMigrator._update_column.<locals>.<listcomp>)ZforeignZprimaryc                 S   s   | S r   r   ©Ú
column_defr   r   r   Ú<lambda>S  ó    z/SqliteMigrator._update_column.<locals>.<lambda>c                 S   s   d S r   r   r£   r   r   r   r¥   V  r¦   c                    s   ˆj  dˆ  | ¡S )NzFOREIGN KEY ("%s") )Úfk_reÚsubr£   ©Ú
new_columnr   r   r   r¥   Y  s   þr   Z__tmp__z
("?)%s("?)z\1%s\2ú, zDROP TABLE IF EXISTSz%s (%s)zINSERT INTOc                 S   s   g | ]}t |ƒ‘qS r   r   r¡   r   r   r   r]   v  s     ZSELECTc                 S   s   g | ]}t |ƒ‘qS r   r   r¡   r   r   r   r]   x  s     ZFROMz
DROP TABLEc                 S   s   | j S r   )r   )Úidxr   r   r   r¥   …  r¦   )%Úsetr   Zget_columnsrœ   rQ   r�   Zget_indexesr^   Úrer¨   Ú	column_reÚsearchÚgroupsÚcolumn_split_reÚfindallÚcolumn_name_reÚmatchrT   Ú
startswithr˜   ÚzipÚgetr§   ÚcompileÚIÚjoinr9   r:   r   r    r   r   rn   Úfilterrr   r   Ú
_fix_index)r   r;   Úcolumn_to_updater,   rr   Zcreate_tableZindexesZ
raw_createZraw_columnsZsplit_columnsZcolumn_defsZnew_column_defsZnew_column_namesZoriginal_column_namesr¤   r<   Znew_column_defZoriginal_to_newZfk_filter_fnZcleaned_columnsrµ   Z
temp_tableZrgxZcreateZqueriesZpopulate_tableÚindexr   r   r©   r   Ú_update_column  sž    
ÿÿ



ÿ





þ
þù
þ
zSqliteMigrator._update_columnc           
      C   sÔ   |  |¡}t|ƒdkr"| ||¡S | dd¡\}}t|  |¡ƒdkrXd|| ||¡f S | dd¡d   d¡}dd	„ |D ƒ}g }|D ]2}	t d
| |	¡r¬t|	t|ƒd …  }	| |	¡ q„d|d dd„ |D ƒ¡f S )Né   ú(r   z%s(%sú)r   ú,c                 S   s   g | ]}|  d ¡‘qS )z"`[]' rŸ   )r\   Úpartr   r   r   r]   ¡  s     z-SqliteMigrator._fix_index.<locals>.<listcomp>z%s(?:['"`\]]?\s|$)z%s(%s)r«   c                 s   s   | ]}d | V  qdS )z"%s"Nr   )r\   Úcr   r   r   r—   ¬  s     z,SqliteMigrator._fix_index.<locals>.<genexpr>)	Úsplitr�   ÚreplaceÚrsplitr®   rµ   Znew_columnerT   r»   )
r   r   r¾   rª   rF   ZlhsZrhsrr   Zcleanr[   r   r   r   r½   �  s    
zSqliteMigrator._fix_indexTc                 C   s   |   ||dd„ ¡S )Nc                 S   s   d S r   r   )ÚaÚbr   r   r   r¥   °  r¦   z,SqliteMigrator.drop_column.<locals>.<lambda>©rÀ   )r   r;   r<   r`   r   r   r   rb   ®  s    zSqliteMigrator.drop_columnc                    s   ‡ fdd„}|   |||¡S )Nc                    s   |  | ˆ ¡S r   ©rÈ   ©r<   r¤   ©rf   r   r   Ú_rename´  s    z-SqliteMigrator.rename_column.<locals>._renamerÌ   )r   r;   re   rf   rÐ   r   rÏ   r   rg   ²  s    zSqliteMigrator.rename_columnc                 C   s   dd„ }|   |||¡S )Nc                 S   s   |d S )Nz	 NOT NULLr   rÎ   r   r   r   Ú_add_not_nullº  s    z2SqliteMigrator.add_not_null.<locals>._add_not_nullrÌ   )r   r;   r[   rÑ   r   r   r   rR   ¸  s    zSqliteMigrator.add_not_nullc                 C   s   dd„ }|   |||¡S )Nc                 S   s   |  dd¡S )Nr�   Ú rÍ   rÎ   r   r   r   Ú_drop_not_nullÀ  s    z4SqliteMigrator.drop_not_null.<locals>._drop_not_nullrÌ   )r   r;   r[   rÓ   r   r   r   rl   ¾  s    zSqliteMigrator.drop_not_nullN)T)r&   r'   r(   r)   r®   r¹   r¯   r²   r´   rº   r§   r›   r�   r0   rÀ   r½   rb   rg   rR   rl   r   r   r   r   r4   	  s$   



p

r4   c                  O   s   | D ]}|  ¡  qd S r   )r   )rV   r   r0   r   r   r   ÚmigrateÅ  s    rÔ   )r)   Úcollectionsr   r.   r®   Zpeeweer   r   r   r   r	   r
   Úobjectr   r0   r1   r2   Z_column_attributesrŠ   r3   r4   rÔ   r   r   r   r   Ú<module>   s*   e 	 -'"v =