Fix pre-upgrade check for rows dangling w.r.t. dag_run (#22850)
Fix pre-upgrade check for rows dangling w.r.t. dag_run (#22850)

Some migrations for 2.3.0 add keys to TI and DR.

We have a check that purges any rows that can't be mapped to a DR.

But it doesn't work correctly. It does DELETE FROM USING dag_run; but this is an inner join so if the dag run isn't there the rows won't be deleted.

Instead we can do DELETE FROM WHERE NOT EXISTS. This has a happy side effect of letting us remove some dialect-specific code.

This PR does not add a check for dangling w.r.t. TI -- that is deferred for a later PR.
danielvdende/incubator-airflow,apache/airflow,Acehaidrey/incubator-airflow,cfei18/incubator-airflow,Acehaidrey/incubator-airflow,danielvdende/incubator-airflow,cfei18/incubator-airflow,nathanielvarona/airflow,apache/airflow,cfei18/incubator-airflow,danielvdende/incubator-airflow,nathanielvarona/airflow,Acehaidrey/incubator-airflow,danielvdende/incubator-airflow,lyft/incubator-airflow,nathanielvarona/airflow,apache/airflow,cfei18/incubator-airflow,danielvdende/incubator-airflow,lyft/incubator-airflow,nathanielvarona/airflow,Acehaidrey/incubator-airflow,apache/airflow,Acehaidrey/incubator-airflow,danielvdende/incubator-airflow,lyft/incubator-airflow,apache/airflow,cfei18/incubator-airflow,lyft/incubator-airflow,cfei18/incubator-airflow,apache/airflow,Acehaidrey/incubator-airflow,nathanielvarona/airflow,nathanielvarona/airflow