ephraimbuddy commented on a change in pull request #21273:
URL: https://github.com/apache/airflow/pull/21273#discussion_r803363777



##########
File path: 
airflow/migrations/versions/5e3ec427fdd3_increase_length_of_email_and_username.py
##########
@@ -46,9 +46,11 @@ def upgrade():
 
 def downgrade():
     """Revert length of email from 256 to 64 characters"""
-    with op.batch_alter_table('ab_user') as batch_op:
-        batch_op.alter_column('username', type_=sa.String(64))
-        batch_op.alter_column('email', type_=sa.String(64))
-    with op.batch_alter_table('ab_register_user') as batch_op:
-        batch_op.alter_column('username', type_=sa.String(64))
-        batch_op.alter_column('email', type_=sa.String(64))
+    conn = op.get_bind()
+    if conn.dialect.name != 'mssql':

Review comment:
       MSSQL has an implicit unique check constraint on the fields and couldn't 
be dropped even when I added `mssql_drop_check=True` to the 
alter_column(https://alembic.sqlalchemy.org/en/latest/ops.html#alembic.operations.Operations.drop_column.params.mssql_drop_check).
   The error is :
   ```
   sqlalchemy.exc.ProgrammingError: (pyodbc.ProgrammingError) ('42000', 
"[42000] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]The object 
'UQ__ab_user__F3DBC572531AB6DC' is dependent on column 'username'. (5074) 
(SQLExecDirectW)")
   [SQL: ALTER TABLE ab_user ALTER COLUMN username VARCHAR(64) NOT NULL]
   ```
   I'll be adding a naming convention in 
https://github.com/apache/airflow/pull/21462 so we can always reason out the 
name of the implicit key and drop them anytime we want(for new db). Since this 
key is randomly generated, it can be different in different deployments, so I 
avoided dropping it for mssql




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to