Apply specific ID collation to root_dag_id too (#23536)
authorMichael Peteuil <michael.peteuil@gmail.com>
Mon, 9 May 2022 17:48:11 +0000 (13:48 -0400)
committerGitHub <noreply@github.com>
Mon, 9 May 2022 17:48:11 +0000 (19:48 +0200)
commitb7f862760ce4e20a284bb1933c9078e54851c518
tree2e23b758729f2ed08e93da19cfe2df31d23589f5
parent428a43995390b3623a51aa7bac7e21da69a8db22
Apply specific ID collation to root_dag_id too (#23536)

In certain databases there is a need to set the collation for ID fields
like dag_id or task_id to something different than the database default.
This is because in MySQL with utf8mb4 the index size becomes too big for
the MySQL limits. In past pull requests this was handled
[#7570](https://github.com/apache/airflow/pull/7570),
[#17729](https://github.com/apache/airflow/pull/17729), but the
root_dag_id field on the dag model was missed. Since this field is used
to join with the dag_id in various other models ([and
self-referentially](https://github.com/apache/airflow/blob/451c7cbc42a83a180c4362693508ed33dd1d1dab/airflow/models/dag.py#L2766)),
it also needs to have the same collation as other ID fields.

This can be seen by running `airflow db reset` before and after applying
this change while also specifying `sql_engine_collation_for_ids` in the
configuration.

Other related PRs
[#19408](https://github.com/apache/airflow/pull/19408)
airflow/migrations/versions/0045_b3b105409875_add_root_dag_id_to_dag.py