Mottimo commented on issue #24247:
URL: https://github.com/apache/airflow/issues/24247#issuecomment-1147671337

   My DB was create with Airflow 2.0, then migrated till now. The suggestion 
from @AlekseiSaff has fixed the first part of the upgrade, now we got another 
error:
   
   `sqlalchemy.exc.OperationalError: (MySQLdb._exceptions.OperationalError) 
(1091, "Can't DROP FOREIGN KEY `task_reschedule_ti_fkey`; check that it 
exists")`
   
   This foreign key seems that cannot be created as reported into the migration 
script, that is this statement does not work:
   
   `ALTER TABLE task_reschedule ADD CONSTRAINT task_reschedule_ti_fkey FOREIGN 
KEY (dag_id, task_id, run_id, map_index) REFERENCES task_instance (dag_id, 
task_id, run_id, map_index);`
   ERROR 1005 (HY000): Can't create table `bee`.`task_reschedule` (errno: 150 
"Foreign key constraint is incorrectly formed")
   
   but this one does:
   
   `ALTER TABLE task_reschedule ADD CONSTRAINT task_reschedule_ti_fkey FOREIGN 
KEY (dag_id, task_id, run_id) REFERENCES task_instance (dag_id, task_id, 
run_id);`
   Query OK, 0 rows affected (0.009 sec)
   Records: 0  Duplicates: 0  Warnings: 0
   
   The portion of the script should be this one:
   
   `with op.batch_alter_table("task_reschedule") as batch_op:
           batch_op.add_column(Column("map_index", Integer, nullable=False, 
server_default=text("-1")))
           batch_op.create_foreign_key(
               "task_reschedule_ti_fkey",
               "task_instance",
               ["dag_id", "task_id", "run_id", "map_index"],
               ["dag_id", "task_id", "run_id", "map_index"],
               ondelete="CASCADE",
           )
           batch_op.create_index(
               "idx_task_reschedule_dag_task_run",
               ["dag_id", "task_id", "run_id", "map_index"],
               unique=False,
           )`
   
   Then, something does not work in our schema with field map_index...
   


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