관리-도구
편집 파일: postgresql.cpython-38.pyc
U 0?�f�t � @ s* d dl mZ d dlZd dlZd dlmZ d dlmZ d dlmZ d dlmZ d dlm Z d dlm Z d d lmZ d d lmZ d dlm Z d dlmZ d d lmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dl m!Z! ddl"m#Z# ddl"m$Z$ ddl"m%Z% ddl"m&Z& ddl"m'Z' ddl"m(Z( dd l"m)Z) dd!l"m*Z* dd"l"m+Z+ dd#l,m-Z- dd$l,m.Z. d%d&l/m0Z0 d%d'l1m2Z2 d%d(l3m4Z4 d%d)l3m5Z5 d%d*l6m7Z7 d%d+l6m8Z8 d%d,l0m9Z9 d%d-l:m;Z; e�r�d d.lm<Z< d d/lm=Z= d d0lm>Z> d d1l?m@Z@ d d2lAmBZB d d3lCmDZD d d4lEmFZF d d5lEmGZG d d6lmHZH d d7lmIZI d d8lmJZJ d d9lKmLZL d d:lKmMZM d d;lNmOZO dd<l"mPZP d%d=lQmRZR d%d>lSmTZT d%d?lUmVZV e�WeX�ZYG d@dA� dAe.�ZZG dBdC� dCe%�Z[e;e+dD�dEdFdGdH�dIdJ��Z\e;e[dD�dCdFdGdH�dKdL��Z]e;e&dD�dMdFdGdH�dNdO��Z^e;e*dD�dPdFdQ�dRdS��Z_e8�`dT�e7�`dTdU�e4ja�bdV�G dWdX� dXe4ja����Zce2jd�eec�dYdXdGdZ�d[d\��Zfe2jg�ee�d]dYd^dGd_�d`da��ZhdYdGdb�dcdd�Zid]dYdedGdf�dgdh�ZjdidYdGdj�dkdl�ZkdS )m� )�annotationsN)�Any)�cast)�Dict)�List)�Optional)�Sequence)�Tuple)� TYPE_CHECKING)�Union)�Column)�literal_column)�Numeric)�text)�types)�BIGINT)�ExcludeConstraint)�INTEGER)�CreateIndex)�ColumnClause)� TextClause)�FunctionElement)�NULLTYPE� )�alter_column)�alter_table)�AlterColumn)� ColumnComment)�format_column_name)�format_table_name)�format_type)�IdentityColumnDefault)�RenameTable)�ComparisonResult)�DefaultImpl� )�util)�render)�ops)� schemaobj)�BatchOperations)� Operations)�sqla_compat)�compiles)�Literal)�Index)�UniqueConstraint)�ARRAY)� PGDDLCompiler)�HSTORE)�JSON)�JSONB)� ClauseElement)� ColumnElement)�quoted_name)�MetaData)�Table)� TypeEngine)�_ServerDefault)�AutogenContext)�_f_name)�MigrationContextc s� e Zd ZdZdZejddhf Zdddd�d d �Zdd� Zd d� Z dRddddddddddddddd�� fdd� Z dd� Zdd� Ze �d�e �d�e �d �e �d!�e �d"�fZdddd#�d$d%�Zd&d'd(�d)d*�Zddd+d,�d-d.�Zd/d/d+d0�d1d2�Zd3dd3d4�d5d6�Zd7dd8�d9d:�ZdSd;d<d<ddd=�� fd>d?� Zd@dAdBdC�dDdE�ZdFdAddC�dGdH�ZdIdAddC�dJdK�ZdLdAddC�dMdN�ZdOdAddC�dPdQ�Z� ZS )T�PostgresqlImpl� postgresqlT�FLOATzDOUBLE PRECISIONr/ r �None)�index�kw�returnc K sR |j �dd �pd}|D ]$}||jjkr|j�t|tj�� q| �t |f|�� d S )N�postgresql_include� ) �kwargs�get�table�c� append_columnr �sqltypesZNullType�_execr )�selfrD rE rG �colrH rH �D/opt/hc_python/lib/python3.8/site-packages/alembic/ddl/postgresql.py�create_indexU s �zPostgresqlImpl.create_indexc C s0 |j D ]$}|jd k r|j|jkr| �|� qd S �N)�constraints�nameZnamed_constraintsZdrop_constraint)rP Z batch_implrK � constraintrH rH rR �prep_table_for_batcha s � �z#PostgresqlImpl.prep_table_for_batchc C s� |j r||jjkrdS |}||k}|r*dS d |||jfkr@| S |jj}t|t�r�t|jt�sxt � dd|�}d|� d�}t|�}| j}|d k s�t �|�t�t|�|k�� S )NFz^'|'$� �')Zprimary_keyrK Z_autoincrement_column�server_default�arg� isinstance�str�typer �re�subr � connection�AssertionErrorZscalarr, �_select) rP Zinspector_columnZmetadata_columnZrendered_metadata_defaultZrendered_inspector_defaultZconn_col_defaultZdefaults_equalZmetadata_default�connrH rH rR �compare_server_defaulti s8 � �� ��z%PostgresqlImpl.compare_server_defaultNFr^ zOptional[bool]z%Union[_ServerDefault, Literal[False]]� Optional[str]zOptional[TypeEngine]zOptional[_ServerDefault])� table_name�column_name�nullabler[ rV �type_�schema� autoincrement� existing_type�existing_server_default�existing_nullable�existing_autoincrementrE rF c sz | � dd �}|d k r&|d kr&t�d��|d k rL| �t|||||| | |d�� t� j||f|||||| | ||d� | �� d S )NZpostgresql_usingz6postgresql_using must be used with the type_ parameter)rl �usingrn ro rp ) rj r[ rV rl rm rn ro rp rq )�popr&