esthomw commented on issue #24526:
URL: https://github.com/apache/airflow/issues/24526#issuecomment-1181627863

   Hi,
   
   I managed to run migrations with some small manual changes to database 
before running `airflow db upgrade`. I was upgrading from 2.2.3 to 2.3.2. The 
main culprit in that situation was misaligned CHARSET/COLLATE for task_id and 
dag_id column between multiple tables. Here is the script I used to align those 
columns:
   
   ```sql
   -- remove foreign key temporarily as it is used by one of modified columns
   ALTER TABLE task_reschedule DROP FOREIGN KEY task_reschedule_ti_fkey;
   
   ALTER TABLE task_instance MODIFY task_id VARCHAR(255) CHARACTER SET utf8 
COLLATE utf8_bin;
   ALTER TABLE task_reschedule MODIFY task_id VARCHAR(255) CHARACTER SET utf8 
COLLATE utf8_bin;
   ALTER TABLE rendered_task_instance_fields MODIFY task_id VARCHAR(255) 
CHARACTER SET utf8 COLLATE utf8_bin;
   ALTER TABLE rendered_task_instance_fields MODIFY dag_id VARCHAR(255) 
CHARACTER SET utf8 COLLATE utf8_bin;
   ALTER TABLE task_fail MODIFY task_id VARCHAR(255) CHARACTER SET utf8 COLLATE 
utf8_bin;
   ALTER TABLE task_fail MODIFY dag_id VARCHAR(255) CHARACTER SET utf8 COLLATE 
utf8_bin;
   
   -- reintroduce the key (otherwise migrations should fail)
   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);
   ```


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