jedcunningham commented on code in PR #24488:
URL: https://github.com/apache/airflow/pull/24488#discussion_r898699315


##########
airflow/migrations/versions/0111_2_4_0_add_indexes_for_cascade_deletes.py:
##########
@@ -0,0 +1,68 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Add indexes for CASCADE deletes
+
+Revision ID: f5fcbda3e651
+Revises: 3c94c427fdf6
+Create Date: 2022-06-15 18:04:54.081789
+
+"""
+
+from alembic import op
+
+# revision identifiers, used by Alembic.
+revision = 'f5fcbda3e651'
+down_revision = '3c94c427fdf6'
+branch_labels = None
+depends_on = None
+airflow_version = '2.4.0'
+
+
+def upgrade():
+    """Apply Add indexes for CASCADE deletes"""
+    # ### commands auto generated by Alembic - please adjust! ###

Review Comment:
   ```suggestion
   ```
   
   nit



##########
airflow/models/taskfail.py:
##########
@@ -39,6 +39,7 @@ class TaskFail(Base):
     duration = Column(Integer)
 
     __table_args__ = (
+        Index("idx_task_fail_task_instance", dag_id, task_id, run_id, 
map_index, unique=False),

Review Comment:
   ```suggestion
           Index("idx_task_fail_task_instance", dag_id, task_id, run_id, 
map_index),
   ```
   
   That's the default, no?



##########
airflow/migrations/versions/0111_2_4_0_add_indexes_for_cascade_deletes.py:
##########
@@ -0,0 +1,68 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Add indexes for CASCADE deletes
+
+Revision ID: f5fcbda3e651
+Revises: 3c94c427fdf6
+Create Date: 2022-06-15 18:04:54.081789
+
+"""
+
+from alembic import op
+
+# revision identifiers, used by Alembic.
+revision = 'f5fcbda3e651'
+down_revision = '3c94c427fdf6'
+branch_labels = None
+depends_on = None
+airflow_version = '2.4.0'
+
+
+def upgrade():
+    """Apply Add indexes for CASCADE deletes"""
+    # ### commands auto generated by Alembic - please adjust! ###
+    with op.batch_alter_table('task_fail', schema=None) as batch_op:
+        batch_op.create_index(
+            'idx_task_fail_task_instance', ['dag_id', 'task_id', 'run_id', 
'map_index'], unique=False
+        )
+
+    with op.batch_alter_table('task_reschedule', schema=None) as batch_op:
+        batch_op.create_index('idx_task_reschedule_dag_run', ['dag_id', 
'run_id'], unique=False)
+
+    with op.batch_alter_table('xcom', schema=None) as batch_op:
+        batch_op.create_index(
+            'idx_xcom_task_instance', ['dag_id', 'task_id', 'run_id', 
'map_index'], unique=False
+        )
+
+    # ### end Alembic commands ###

Review Comment:
   ```suggestion
   ```



##########
airflow/migrations/versions/0111_2_4_0_add_indexes_for_cascade_deletes.py:
##########
@@ -0,0 +1,68 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Add indexes for CASCADE deletes
+
+Revision ID: f5fcbda3e651
+Revises: 3c94c427fdf6
+Create Date: 2022-06-15 18:04:54.081789
+
+"""
+
+from alembic import op
+
+# revision identifiers, used by Alembic.
+revision = 'f5fcbda3e651'
+down_revision = '3c94c427fdf6'
+branch_labels = None
+depends_on = None
+airflow_version = '2.4.0'
+
+
+def upgrade():
+    """Apply Add indexes for CASCADE deletes"""
+    # ### commands auto generated by Alembic - please adjust! ###
+    with op.batch_alter_table('task_fail', schema=None) as batch_op:
+        batch_op.create_index(
+            'idx_task_fail_task_instance', ['dag_id', 'task_id', 'run_id', 
'map_index'], unique=False
+        )
+
+    with op.batch_alter_table('task_reschedule', schema=None) as batch_op:
+        batch_op.create_index('idx_task_reschedule_dag_run', ['dag_id', 
'run_id'], unique=False)
+
+    with op.batch_alter_table('xcom', schema=None) as batch_op:
+        batch_op.create_index(
+            'idx_xcom_task_instance', ['dag_id', 'task_id', 'run_id', 
'map_index'], unique=False
+        )
+
+    # ### end Alembic commands ###
+
+
+def downgrade():
+    """Unapply Add indexes for CASCADE deletes"""
+    # ### commands auto generated by Alembic - please adjust! ###

Review Comment:
   ```suggestion
   ```



##########
airflow/migrations/versions/0111_2_4_0_add_indexes_for_cascade_deletes.py:
##########
@@ -0,0 +1,68 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Add indexes for CASCADE deletes
+
+Revision ID: f5fcbda3e651
+Revises: 3c94c427fdf6
+Create Date: 2022-06-15 18:04:54.081789
+
+"""
+
+from alembic import op
+
+# revision identifiers, used by Alembic.
+revision = 'f5fcbda3e651'
+down_revision = '3c94c427fdf6'
+branch_labels = None
+depends_on = None
+airflow_version = '2.4.0'

Review Comment:
   ```suggestion
   airflow_version = '2.3.3'
   ```
   
   We should pull this into the next release.



##########
airflow/migrations/versions/0111_2_4_0_add_indexes_for_cascade_deletes.py:
##########
@@ -0,0 +1,68 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Add indexes for CASCADE deletes
+
+Revision ID: f5fcbda3e651
+Revises: 3c94c427fdf6
+Create Date: 2022-06-15 18:04:54.081789
+
+"""
+
+from alembic import op
+
+# revision identifiers, used by Alembic.
+revision = 'f5fcbda3e651'
+down_revision = '3c94c427fdf6'
+branch_labels = None
+depends_on = None
+airflow_version = '2.4.0'
+
+
+def upgrade():
+    """Apply Add indexes for CASCADE deletes"""
+    # ### commands auto generated by Alembic - please adjust! ###
+    with op.batch_alter_table('task_fail', schema=None) as batch_op:
+        batch_op.create_index(
+            'idx_task_fail_task_instance', ['dag_id', 'task_id', 'run_id', 
'map_index'], unique=False
+        )
+
+    with op.batch_alter_table('task_reschedule', schema=None) as batch_op:
+        batch_op.create_index('idx_task_reschedule_dag_run', ['dag_id', 
'run_id'], unique=False)
+
+    with op.batch_alter_table('xcom', schema=None) as batch_op:
+        batch_op.create_index(
+            'idx_xcom_task_instance', ['dag_id', 'task_id', 'run_id', 
'map_index'], unique=False

Review Comment:
   ```suggestion
               'idx_xcom_task_instance', ['dag_id', 'task_id', 'run_id', 
'map_index']
   ```



##########
airflow/models/taskreschedule.py:
##########
@@ -61,6 +61,7 @@ class TaskReschedule(Base):
             name="task_reschedule_ti_fkey",
             ondelete="CASCADE",
         ),
+        Index('idx_task_reschedule_dag_run', dag_id, run_id, unique=False),

Review Comment:
   ```suggestion
           Index('idx_task_reschedule_dag_run', dag_id, run_id),
   ```



##########
airflow/migrations/versions/0111_2_4_0_add_indexes_for_cascade_deletes.py:
##########
@@ -0,0 +1,68 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Add indexes for CASCADE deletes
+
+Revision ID: f5fcbda3e651
+Revises: 3c94c427fdf6
+Create Date: 2022-06-15 18:04:54.081789
+
+"""
+
+from alembic import op
+
+# revision identifiers, used by Alembic.
+revision = 'f5fcbda3e651'
+down_revision = '3c94c427fdf6'
+branch_labels = None
+depends_on = None
+airflow_version = '2.4.0'
+
+
+def upgrade():
+    """Apply Add indexes for CASCADE deletes"""
+    # ### commands auto generated by Alembic - please adjust! ###
+    with op.batch_alter_table('task_fail', schema=None) as batch_op:
+        batch_op.create_index(
+            'idx_task_fail_task_instance', ['dag_id', 'task_id', 'run_id', 
'map_index'], unique=False
+        )
+
+    with op.batch_alter_table('task_reschedule', schema=None) as batch_op:
+        batch_op.create_index('idx_task_reschedule_dag_run', ['dag_id', 
'run_id'], unique=False)

Review Comment:
   ```suggestion
           batch_op.create_index('idx_task_reschedule_dag_run', ['dag_id', 
'run_id'])
   ```



##########
airflow/migrations/versions/0111_2_4_0_add_indexes_for_cascade_deletes.py:
##########
@@ -0,0 +1,68 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Add indexes for CASCADE deletes
+
+Revision ID: f5fcbda3e651
+Revises: 3c94c427fdf6
+Create Date: 2022-06-15 18:04:54.081789
+
+"""
+
+from alembic import op
+
+# revision identifiers, used by Alembic.
+revision = 'f5fcbda3e651'
+down_revision = '3c94c427fdf6'
+branch_labels = None
+depends_on = None
+airflow_version = '2.4.0'
+
+
+def upgrade():
+    """Apply Add indexes for CASCADE deletes"""
+    # ### commands auto generated by Alembic - please adjust! ###
+    with op.batch_alter_table('task_fail', schema=None) as batch_op:
+        batch_op.create_index(
+            'idx_task_fail_task_instance', ['dag_id', 'task_id', 'run_id', 
'map_index'], unique=False

Review Comment:
   ```suggestion
               'idx_task_fail_task_instance', ['dag_id', 'task_id', 'run_id', 
'map_index']
   ```
   
   Same here.



##########
airflow/migrations/versions/0111_2_4_0_add_indexes_for_cascade_deletes.py:
##########
@@ -0,0 +1,68 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Add indexes for CASCADE deletes
+
+Revision ID: f5fcbda3e651
+Revises: 3c94c427fdf6
+Create Date: 2022-06-15 18:04:54.081789
+
+"""
+
+from alembic import op
+
+# revision identifiers, used by Alembic.
+revision = 'f5fcbda3e651'
+down_revision = '3c94c427fdf6'
+branch_labels = None
+depends_on = None
+airflow_version = '2.4.0'
+
+
+def upgrade():
+    """Apply Add indexes for CASCADE deletes"""
+    # ### commands auto generated by Alembic - please adjust! ###
+    with op.batch_alter_table('task_fail', schema=None) as batch_op:
+        batch_op.create_index(
+            'idx_task_fail_task_instance', ['dag_id', 'task_id', 'run_id', 
'map_index'], unique=False
+        )
+
+    with op.batch_alter_table('task_reschedule', schema=None) as batch_op:
+        batch_op.create_index('idx_task_reschedule_dag_run', ['dag_id', 
'run_id'], unique=False)
+
+    with op.batch_alter_table('xcom', schema=None) as batch_op:
+        batch_op.create_index(
+            'idx_xcom_task_instance', ['dag_id', 'task_id', 'run_id', 
'map_index'], unique=False
+        )
+
+    # ### end Alembic commands ###
+
+
+def downgrade():
+    """Unapply Add indexes for CASCADE deletes"""
+    # ### commands auto generated by Alembic - please adjust! ###
+    with op.batch_alter_table('xcom', schema=None) as batch_op:
+        batch_op.drop_index('idx_xcom_task_instance')
+
+    with op.batch_alter_table('task_reschedule', schema=None) as batch_op:
+        batch_op.drop_index('idx_task_reschedule_dag_run')
+
+    with op.batch_alter_table('task_fail', schema=None) as batch_op:
+        batch_op.drop_index('idx_task_fail_task_instance')
+
+    # ### end Alembic commands ###

Review Comment:
   ```suggestion
   ```



-- 
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