o
    h                     @   sJ   d Z ddlmZ ddlmZ dd Zdd Zdd	 ZG d
d dejZdS )z
To understand why this file is here, please read:

http://cookiecutter-django.readthedocs.io/en/latest/faq.html#why-is-there-a-django-contrib-sites-directory-in-cookiecutter-django
    )settings)
migrationsc           	      C   s   | j jtj||dd\}}|rO| j d j}| (}|d |	 \}||kr=|d|d g W d   dS W d   dS 1 sHw   Y  dS dS )zKUpdate or create the site with default ID and keep the DB sequence in sync.)domainname)iddefaultsz-idz)SELECT last_value from django_site_id_seqz1alter sequence django_site_id_seq restart with %s   N)
objectsupdate_or_creater   SITE_IDorder_byfirstr   cursorexecutefetchone)	
site_model
connectionr   r   sitecreatedmax_idr   
current_id r   Y/var/www/html/mimamsha/mimansha/contrib/sites/migrations/0003_set_site_domain_and_name.py$_update_or_create_site_with_sequence
   s(   



"r   c                 C   s    |  dd}t||jdd dS )zSet site domain and name.sitesSitezpawanparichit.commimanshaN	get_modelr   r   appsschema_editorr   r   r   r   update_site_forward%      r"   c                 C   s    |  dd}t||jdd dS )z'Revert site domain and name to default.r   r   zexample.comNr   r   r   r   r   update_site_backward0   r#   r$   c                   @   s    e Zd ZdgZeeegZdS )	Migration)r   0002_alter_domain_uniqueN)	__name__
__module____qualname__dependenciesr   	RunPythonr"   r$   
operationsr   r   r   r   r%   ;   s    r%   N)	__doc__django.confr   	django.dbr   r   r"   r$   r%   r   r   r   r   <module>   s    