ephraimbuddy commented on a change in pull request #21273:
URL: https://github.com/apache/airflow/pull/21273#discussion_r807108978
##########
File path:
airflow/migrations/versions/7b2661a43ba3_taskinstance_keyed_to_dagrun.py
##########
@@ -337,7 +337,7 @@ def downgrade():
batch_op.drop_constraint('task_instance_pkey', type_='primary')
batch_op.alter_column('execution_date', existing_type=dt_type,
existing_nullable=True, nullable=False)
batch_op.alter_column(
- 'dag_id', existing_type=string_id_col_type,
existing_nullable=True, nullable=True
+ 'dag_id', existing_type=string_id_col_type,
existing_nullable=True, nullable=False
Review comment:
MSSQL refused to drop the index `task_instance_pkey` it created on the
table. I have tried different things but none is working.
One thing that revealed what's happening to me was this `op.execute('alter
table task_instance DROP INDEX task_instance_pkey')` :
```python
batch_op.drop_constraint('task_instance_dag_run_fkey',
type_='foreignkey')
batch_op.drop_constraint('task_instance_pkey', type_='primary')
batch_op.drop_index('ti_dag_run')
batch_op.drop_index('ti_state_lkp')
batch_op.drop_column('run_id')
batch_op.alter_column('execution_date', existing_type=dt_type,
existing_nullable=True, nullable=False)
batch_op.alter_column(
'dag_id', existing_type=string_id_col_type, existing_nullable=False,
nullable=True
)
batch_op.drop_constraint('task_instance_pkey', type_='primary')
if dialect_name == 'mssql':
op.execute('alter table task_instance DROP INDEX task_instance_pkey')
op.execute(
"""
CREATE UNIQUE CLUSTERED INDEX task_instance_pkey
ON task_instance (dag_id, task_id, execution_date)
"""
)
else:
batch_op.create_primary_key('task_instance_pkey', ['dag_id',
'task_id', 'execution_date'])
```
This gives the error that ```The operation 'ALTER TABLE DROP INDEX' is
supported only with memory optimized tables. (10785) (SQLExecDirectW)")
[SQL: alter table task_instance DROP INDEX task_instance_pkey]```
Without the `op.execute('alter table task_instance DROP INDEX
task_instance_pkey')` it gives this error:
```Cannot create more than one clustered index on table 'task_instance'.
Drop the existing clustered index 'task_instance_pkey' before creating
another```
I don't know why the constraint `task_instance_pkey` is not dropping despite
that I called `batch_op.drop_constraint('task_instance_pkey', type_='primary')`
twice.
I will appreciate any helps cc: @jedcunningham @ashb
--
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]