U of'@sddlmZddlZddlmZddlmZddlmZddlmZddlm Z ddlm Z dd l m Z dd lmZdd lmZdd lmZd dlmZd dlmZd dlmZd dlmZd dlmZerFddlmZddlmZddlmZddlmZddlmZddl m!Z!ddl"m#Z#ddl$m%Z%d dlm&Z&d dlm'Z'eddd e(fZ)Gd!d"d"eZ*Gd#d$d$e*Z+Gd%d&d&e*Z,Gd'd(d(e,Z-Gd)d*d*e,Z.Gd+d,d,e,Z/Gd-d.d.e,Z0Gd/d0d0e,Z1Gd1d2d2e,Z2Gd3d4d4e*Z3Gd5d6d6e*Z4Gd7d8d8e,Z5e e+d$d9d:d;dd?Z7e e4d6d9d:d;d@dAZ8e e-d(d9d:d;dBdCZ9e e.d*d9d:d;dDdEZ:e e/d,d9d:d;dFdGZ;e e0d.d9d:d;dHdIZdOdPdOdQdRdSZ?dTdOdUdOdVdWdXZ@d9dUdOdYdZd[ZAd9d\d:d]d^d_ZBd9d`d:dadbdcZCd9d:ddd:dVdedfZDd9d:d:dYdgdhZEd9d:d:dYdidjZFd9dkd:dldmdnZGdS)o) annotationsN)Optional) TYPE_CHECKING)Union)exc)Integer)types)compiles)Column) DDLElement) quoted_name)_columns_for_constraint) _find_columns)_fk_spec)_is_type_bound)_table_for_constraint)Any)Compiled) DDLCompiler) TextClause)Function) FetchedValue) TypeEngine) DefaultImpl)Computed)Identityrrz Function[Any]c@s$eZdZdZd ddddddZdS) AlterTablezRepresent an ALTER TABLE statement. Only the string name and optional schema name of the table is required, not a full Table object. Nstr!Optional[Union[quoted_name, str]]None) table_nameschemareturncCs||_||_dSN)r"r#)selfr"r#r'>/opt/hc_python/lib/python3.8/site-packages/alembic/ddl/base.py__init__2szAlterTable.__init__)N)__name__ __module__ __qualname____doc__r)r'r'r'r(r*s rcs*eZdZd dddddfdd ZZS) RenameTableNrUnion[quoted_name, str]r r!)old_table_namenew_table_namer#r$cstj||d||_dSN)r#)superr)r1)r&r0r1r# __class__r'r(r)<szRenameTable.__init__)Nr*r+r,r) __classcell__r'r'r4r(r.;sr.c s2eZdZd dddddddddfd d ZZS) AlterColumnNr Optional[str]zOptional[TypeEngine]zOptional[bool]Optional[_ServerDefault]r!)name column_namer# existing_typeexisting_nullableexisting_server_defaultexisting_commentr$csDtj||d||_|dk r(t|nd|_||_||_||_dSr2) r3r)r<sqltypes to_instancer=r>r?r@)r&r;r<r#r=r>r?r@r4r'r(r)Gs  zAlterColumn.__init__)NNNNNr6r'r'r4r(r8Fs r8cs(eZdZdddddfdd ZZS)ColumnNullablerboolr!)r;r<nullabler$c stj||f|||_dSr%)r3r)rE)r&r;r<rEkwr4r'r(r)^szColumnNullable.__init__r6r'r'r4r(rC]srCcs(eZdZdddddfdd ZZS) ColumnTyperrr!)r;r<type_r$c s"tj||f|t||_dSr%)r3r)rArBrH)r&r;r<rHrFr4r'r(r)fszColumnType.__init__r6r'r'r4r(rGesrGcs(eZdZdddddfdd ZZS) ColumnNamerr!)r;r<newnamer$c stj||f|||_dSr%)r3r)rJ)r&r;r<rJrFr4r'r(r)nszColumnName.__init__r6r'r'r4r(rImsrIcs(eZdZdddddfdd ZZS) ColumnDefaultrr:r!r;r<defaultr$c stj||f|||_dSr%r3r)rMr&r;r<rMrFr4r'r(r)vszColumnDefault.__init__r6r'r'r4r(rKusrKcs(eZdZdddddfdd ZZS)ComputedColumnDefaultrzOptional[Computed]r!rLc stj||f|||_dSr%rNrOr4r'r(r)szComputedColumnDefault.__init__r6r'r'r4r(rPsrPcs*eZdZddddddfdd ZZS)IdentityColumnDefaultrzOptional[Identity]rr!)r;r<rMimplr$c s"tj||f|||_||_dSr%)r3r)rMrR)r&r;r<rMrRrFr4r'r(r)szIdentityColumnDefault.__init__r6r'r'r4r(rQsrQcs*eZdZd dddddfdd ZZS) AddColumnNr Column[Any]r r!r;columnr#r$cstj||d||_dSr2r3r)rVr&r;rVr#r4r'r(r)szAddColumn.__init__)Nr6r'r'r4r(rSsrScs*eZdZd dddddfdd ZZS) DropColumnNrrTr9r!rUcstj||d||_dSr2rWrXr4r'r(r)szDropColumn.__init__)Nr6r'r'r4r(rYsrYcs(eZdZdddddfdd ZZS) ColumnCommentrr9r!)r;r<commentr$c stj||f|||_dSr%)r3r)r[)r&r;r<r[rFr4r'r(r)szColumnComment.__init__r6r'r'r4r(rZsrZrr)elementcompilerr$cKs$dt||j|jt||j|jfS)Nz%s RENAME TO %s) alter_tabler"r#format_table_namer1r\r]rFr'r'r(visit_rename_tablesracKs$dt||j|jt||jf|fSNz%s %s)r^r"r# add_columnrVr`r'r'r(visit_add_columnsrdcKs&dt||j|jt||jjf|fSrb)r^r"r# drop_columnrVr;r`r'r'r(visit_drop_columnsrfcKs,dt||j|jt||j|jr$dndfS)N%s %s %sz DROP NOT NULLz SET NOT NULL)r^r"r# alter_columnr<rEr`r'r'r(visit_column_nullables   ricKs.dt||j|jt||jdt||jfS)NrgzTYPE %s)r^r"r#rhr< format_typerHr`r'r'r(visit_column_types  rkcKs*dt||j|jt||jt||jfS)Nz%s RENAME %s TO %s)r^r"r#format_column_namer<rJr`r'r'r(visit_column_names   rmcKs<dt||j|jt||j|jdk r4dt||jndfS)NrgzSET DEFAULT %sz DROP DEFAULT)r^r"r#rhr<rMformat_server_defaultr`r'r'r(visit_column_defaults ro)r\r]cKstddS)NztAdding or removing a "computed" construct, e.g. GENERATED ALWAYS AS, to or from an existing column is not supported.r CompileErrorr`r'r'r(visit_computed_columnsrrcKstddS)NzAdding, removing or modifying an "identity" construct, e.g. GENERATED AS IDENTITY, to or from an existing column is not supported in this dialect.rpr`r'r'r(visit_identity_columnsrsr/zfunctools.partial)r;quoter$cs4t|tr|Sdfdd|dD}|S)z#quote the elements of a dotted name.csg|] }|qSr'r').0xrtr'r( sz quote_dotted..) isinstancer joinsplit)r;rtresultr'rxr( quote_dotted s r~rr )r]r;r#r$cCs4t|jj}|r(t||d||S||SdS)Nru) functoolspartialpreparerrtr~)r]r;r#rtr'r'r(r_sr_)r]r;r$cCs |j|Sr%)rrtr]r;r'r'r(rl$srlr:)r]rMr$cCs|tdt|dS)Nrw)Zserver_default)Zget_column_default_stringr r)r]rMr'r'r(rn*s rnr)r]rHr$cCs|jj|Sr%)dialectZ type_compilerprocess)r]rHr'r'r(rj3srjr9cCsdt|||S)NzALTER TABLE %s)r_)r]r;r#r'r'r(r^7sr^cKsdt||S)NzDROP COLUMN %srl)r]r;rFr'r'r(re?srecCsdt||S)NzALTER COLUMN %srrr'r'r(rhCsrhrT)r]rVr$c s@dj|f|}dfdd|jD}|r<|d|7}|S)Nz ADD COLUMN %s c3s|]}|VqdSr%)r)rv constraintr]r'r( Jszadd_column..)Zget_column_specificationr{ constraints)r]rVrFtextconstr'rr(rcGs rc)H __future__rrtypingrrrZ sqlalchemyrrrrAZsqlalchemy.ext.compilerr Zsqlalchemy.schemar r Zsqlalchemy.sql.elementsr Zutil.sqla_compatrrrrrrZsqlalchemy.sql.compilerrrrZsqlalchemy.sql.functionsrZsqlalchemy.sql.schemarZsqlalchemy.sql.type_apirrRrrrrZ_ServerDefaultrr.r8rCrGrIrKrPrQrSrYrZrardrfrirkrmrorrrsr~r_rlrnrjr^rerhrcr'r'r'r(s