관리-도구
편집 파일: postgresql.cpython-311.pyc
� �܋fU` � �N � 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 dl mZ d dl mZ d d l mZ d dl mZ d dl mZ d dl mZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlm Z d dl!m"Z" d dl#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. dd%l%m/Z/ dd&l0m1Z1 d'd(l2m3Z3 d'd)l4m5Z5 d'd*l6m7Z7 d'd+l6m8Z8 d'd,l9m:Z: d'd-l9m;Z; d'd.l3m<Z< er`d d/lm=Z= d d0l>m?Z? d d1l@mAZA d d2lBmCZC d d3lDmEZE d d4lDmFZF d d5lmGZG d d6lmHZH d d7lmIZI d d8lJmKZK d d9lJmLZL d d:lMmNZN dd;l%mOZO d'd<lPmQZQ d'd=lRmSZS d'd>lTmUZU ejV eW� � ZX G d?� d@e1� � ZY G dA� dBe(� � ZZ e*e/dC� � dedJ�� � Z[ e*eZdC� � dfdK�� � Z\ e*e)dC� � dgdM�� � Z] e*e.dC� � dhdO�� � Z^ e;j_ dP� � e:j_ dPdQ� � e7j` �a dR� � G dS� dTe7j` � � � � � � � � Zbe5jc �d eb� � didX�� � Zee5jf �d e� � djd]�� � Zgdkd^�Zhdlda�Zidmdd�ZjdS )n� )�annotationsN)�Any)�cast)�List)�Optional)�Sequence)�Tuple)� TYPE_CHECKING)�Union)�Column)�Index)�literal_column)�Numeric)�text)�types)�BIGINT)�ExcludeConstraint)�INTEGER)�CreateIndex)� operators)�ColumnClause)� TextClause)�UnaryExpression)�FunctionElement)�NULLTYPE� )�alter_column)�alter_table)�AlterColumn)� ColumnComment)�compiles)�format_column_name)�format_table_name)�format_type)�IdentityColumnDefault)�RenameTable)�DefaultImpl� )�util)�render)�ops)� schemaobj)�BatchOperations)� Operations)�sqla_compat)�Literal)�ARRAY)� PGDDLCompiler)�HSTORE)�JSON)�JSONB)�BinaryExpression)� ClauseElement)�quoted_name)�MetaData)�Table)� TypeEngine)�_ServerDefault)�AutogenContext)�_f_name)�MigrationContextc �� � � e Zd ZdZdZej ddhfz ZdZd� Zd� Z d� Z d=d>� fd!� Zd"� Zd#� Z d?d(�Zd@d+�ZdAd-�ZdBd/�ZdCd4�ZdDd6�ZdEd8�ZdFd:�ZdGd<�Z� xZS )H�PostgresqlImpl� postgresqlT�FLOATzDOUBLE PRECISION)�on_null�orderc � � |j � dd � � pd}|D ]B}||j j vr2|j � t |t j � � � � �C| � t |� � � � d S )N�postgresql_include� ) �kwargs�get�table�c� append_columnr �sqltypes�NullType�_execr )�self�indexrG �cols �M/opt/cloudlinux/venv/lib64/python3.11/site-packages/alembic/ddl/postgresql.py�create_indexzPostgresqlImpl.create_indexR s� � � #�\�-�-�.B�D�I�I�O�R��%� J� J�C��%�+�-�'�'���)�)�&��h�6G�*H�*H�I�I�I��� � �;�u�%�%�&�&�&�&�&� c �n � |j D ],}|j �#|j |j v r| � |� � �-d S �N)�constraints�name�named_constraints�drop_constraint)rQ � batch_implrK � constraints rT �prep_table_for_batchz#PostgresqlImpl.prep_table_for_batch\ sK � ��+� 1� 1�J���+��O�z�'C�C�C��$�$�Z�0�0�0�� 1� 1rV c � � |j r||j j u rdS |}||k }|rdS d |||j fv r| S |j j }t |t � � rEt |j t � � st j dd|� � }d|� d�}t |� � }| j � t j t |� � |k � � � � S )NFz^'|'$� �')�primary_keyrK �_autoincrement_column�server_default�arg� isinstance�str�typer �re�subr � connection�scalarr/ �_select)rQ �inspector_column�metadata_column�rendered_metadata_default�rendered_inspector_default�conn_col_default�defaults_equal�metadata_defaults rT �compare_server_defaultz%PostgresqlImpl.compare_server_defaulte s � � �'� ��?�#8�#N�N�N��5�5��)�-F�F��� ��5���%��*� � � � &�%�%�*�9�=���&��,�,� @��.�3�W�=�=� ;�#%�6�(�B�8H�#I�#I� �#:�'7�#:�#:�#:� �-�.>�?�?�� �?�)�)����/�0�0�4D�D� � � � � � rV NF� table_namerh �column_name�nullable�Optional[bool]re �%Union[_ServerDefault, Literal[False]]rZ � Optional[str]�type_�Optional[TypeEngine]�schema� autoincrement� existing_type�existing_server_default�Optional[_ServerDefault]�existing_nullable�existing_autoincrement�kwr �return�Nonec � �� | � dd � � }|�|�t j d� � �|�*| � t |||||| | |�� � � � t � � j ||f|||||| | ||d� | �� d S )N�postgresql_usingz6postgresql_using must be used with the type_ parameter)r �usingr� r� r� ) ry re rZ r r� r� r� r� r� )�popr) �CommandErrorrP �PostgresqlColumnType�superr )rQ rw rx ry re rZ r} r r� r� r� r� r� r� r� � __class__s �rT r zPostgresqlImpl.alter_column� s� �� �"