OwlCyberSecurity - MANAGER
Edit File: recorder.cpython-39.pyc
a ���e� � @ sR d dl mZ d dlmZmZ d dlmZ d dlmZ ddl m Z G dd� d�Zd S ) � )�Apps)� DatabaseError�models)� classproperty)�now� )�MigrationSchemaMissingc @ sd e Zd ZdZdZedd� �Zdd� Zedd� �Z d d � Z dd� Zd d� Zdd� Z dd� Zdd� ZdS )�MigrationRecordera� Deal with storing migration records in the database. Because this table is actually itself used for dealing with model creation, it's the one thing we can't do normally via migrations. We manually handle table creation/schema updating (using schema backend) and then have a floating model to do queries with. If a migration is unapplied its row is removed from the table. Having a row in the table always means a migration is applied. Nc C s( | j du r"G dd� dtj�}|| _ | j S )zl Lazy load to avoid AppRegistryNotReady if installed apps import MigrationRecorder. Nc @ sF e Zd Zejdd�Zejdd�Zejed�Z G dd� d�Z dd� ZdS ) z.MigrationRecorder.Migration.<locals>.Migration� )� max_length)�defaultc @ s e Zd Ze� ZdZdZdS )z3MigrationRecorder.Migration.<locals>.Migration.MetaZ migrationsZdjango_migrationsN)�__name__� __module__�__qualname__r ZappsZ app_label�db_table� r r �^/home/gouroczh/virtualenv/pat/3.9/lib/python3.9/site-packages/django/db/migrations/recorder.py�Meta% s r c S s d| j | jf S )NzMigration %s for %s)�name�app��selfr r r �__str__* s z6MigrationRecorder.Migration.<locals>.Migration.__str__N)r r r r Z CharFieldr r Z DateTimeFieldr Zappliedr r r r r r � Migration s r )�_migration_classr ZModel)�clsr r r r r s zMigrationRecorder.Migrationc C s || _ d S �N)� connection)r r r r r �__init__0 s zMigrationRecorder.__init__c C s | j j�| jj�S r )r �objects�usingr �aliasr r r r �migration_qs3 s zMigrationRecorder.migration_qsc C sF | j �� �}| j j�|�}W d � n1 s.0 Y | jjj|v S )z2Return True if the django_migrations table exists.N)r �cursorZ introspectionZtable_namesr �_metar )r r# Ztablesr r r � has_table7 s ,zMigrationRecorder.has_tablec C s| | � � rdS z:| j�� �}|�| j� W d � n1 s:0 Y W n0 tyv } ztd| ��W Y d}~n d}~0 0 dS )z3Ensure the table exists and has the correct schema.Nz1Unable to create the django_migrations table (%s))r% r Z schema_editorZcreate_modelr r r )r Zeditor�excr r r � ensure_schema= s .�zMigrationRecorder.ensure_schemac C s | � � rdd� | jD �S i S dS )z} Return a dict mapping (app_name, migration_name) to Migration instances for all applied migrations. c S s i | ]}|j |jf|�qS r �r r )�.0Z migrationr r r � <dictcomp>R s �z8MigrationRecorder.applied_migrations.<locals>.<dictcomp>N)r% r"