ephraimbuddy commented on code in PR #61976:
URL: https://github.com/apache/airflow/pull/61976#discussion_r2870857791


##########
airflow-core/src/airflow/migrations/versions/0060_3_0_0_add_try_id_to_ti_and_tih.py:
##########
@@ -140,6 +140,18 @@ def downgrade():
             ALTER TABLE task_instance_history DROP COLUMN row_num;
         """
         )
+        # Restore the id column's sequence and default
+        op.execute(
+            "CREATE SEQUENCE IF NOT EXISTS task_instance_history_id_seq OWNED 
BY task_instance_history.id"
+        )
+        op.execute(
+            "SELECT setval('task_instance_history_id_seq', "
+            "COALESCE((SELECT MAX(id) FROM task_instance_history), 1), true)"

Review Comment:
   ```suggestion
               "COALESCE((SELECT MAX(id) FROM task_instance_history), 0), true)"
   ```
   To avoid empty tables starting from ID 2 instead of ID 1. I think this 
should be adjusted to either COALESCE(MAX(id), 0), true or COALESCE(MAX(id), 
1), false



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