From 47128e97fcc6614168c023a3f15db4c38a23eaf5 Mon Sep 17 00:00:00 2001 From: Ephraim Anierobi Date: Sun, 24 Nov 2024 09:40:36 +0100 Subject: [PATCH] fixup! fixup! fix for sqlite --- .../versions/0041_3_0_0_rename_dataset_as_asset.py | 2 -- .../migrations/versions/0048_3_0_0_add_dag_versioning.py | 1 - .../0050_3_0_0_remove_pickled_data_from_xcom_table.py | 7 ++++--- docs/apache-airflow/img/airflow_erd.sha256 | 2 +- tests/utils/test_db.py | 2 ++ 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/airflow/migrations/versions/0041_3_0_0_rename_dataset_as_asset.py b/airflow/migrations/versions/0041_3_0_0_rename_dataset_as_asset.py index 746ca46ec76f3..55dbcdb2c840e 100644 --- a/airflow/migrations/versions/0041_3_0_0_rename_dataset_as_asset.py +++ b/airflow/migrations/versions/0041_3_0_0_rename_dataset_as_asset.py @@ -551,7 +551,6 @@ def downgrade(): with op.batch_alter_table("task_outlet_dataset_reference", schema=None) as batch_op: batch_op.alter_column("asset_id", new_column_name="dataset_id", type_=sa.Integer(), nullable=False) - # batch_op.drop_constraint("toar_asset_fkey", type_="foreignkey") batch_op.drop_constraint("toar_dag_id_fkey", type_="foreignkey") _rename_index( @@ -586,7 +585,6 @@ def downgrade(): with op.batch_alter_table("dataset_dag_run_queue", schema=None) as batch_op: batch_op.alter_column("asset_id", new_column_name="dataset_id", type_=sa.Integer(), nullable=False) - # batch_op.drop_constraint("adrq_asset_fkey", type_="foreignkey") batch_op.drop_constraint("adrq_dag_fkey", type_="foreignkey") _rename_pk_constraint( diff --git a/airflow/migrations/versions/0048_3_0_0_add_dag_versioning.py b/airflow/migrations/versions/0048_3_0_0_add_dag_versioning.py index c76cad5fe82c1..e98bf5a200899 100644 --- a/airflow/migrations/versions/0048_3_0_0_add_dag_versioning.py +++ b/airflow/migrations/versions/0048_3_0_0_add_dag_versioning.py @@ -131,7 +131,6 @@ def upgrade(): def downgrade(): """Unapply add dag versioning.""" - _delete_serdag_and_code() with op.batch_alter_table("task_instance_history", schema=None) as batch_op: batch_op.drop_column("dag_version_id") diff --git a/airflow/migrations/versions/0050_3_0_0_remove_pickled_data_from_xcom_table.py b/airflow/migrations/versions/0050_3_0_0_remove_pickled_data_from_xcom_table.py index ebe8e37a71ff0..ef357824e9efb 100644 --- a/airflow/migrations/versions/0050_3_0_0_remove_pickled_data_from_xcom_table.py +++ b/airflow/migrations/versions/0050_3_0_0_remove_pickled_data_from_xcom_table.py @@ -101,9 +101,9 @@ def upgrade(): op.execute( """ ALTER TABLE xcom - ALTER COLUMN value TYPE JSON + ALTER COLUMN value TYPE JSONB USING CASE - WHEN value IS NOT NULL THEN CAST(CONVERT_FROM(value, 'UTF8') AS JSON) + WHEN value IS NOT NULL THEN CAST(CONVERT_FROM(value, 'UTF8') AS JSONB) ELSE NULL END """ @@ -136,7 +136,6 @@ def upgrade(): # Drop the old `value_old` column with op.batch_alter_table("xcom", schema=None) as batch_op: batch_op.drop_column("value_old") - op.drop_table("_xcom_archive") def downgrade(): @@ -181,3 +180,5 @@ def downgrade(): with op.batch_alter_table("xcom", schema=None) as batch_op: batch_op.drop_column("value_old") + + op.drop_table("_xcom_archive", if_exists=True) diff --git a/docs/apache-airflow/img/airflow_erd.sha256 b/docs/apache-airflow/img/airflow_erd.sha256 index 62d88dfe5a18b..9eeef16072c00 100644 --- a/docs/apache-airflow/img/airflow_erd.sha256 +++ b/docs/apache-airflow/img/airflow_erd.sha256 @@ -1 +1 @@ -a81bc0639419e66abacc09d95177df593b10d8944708212ea2a96a51070b7b31 \ No newline at end of file +65f26e091cabd5c67f45abb682d1ef4fe63cd0d701b5729e5cf95d9cf2599c6a \ No newline at end of file diff --git a/tests/utils/test_db.py b/tests/utils/test_db.py index 1d3412d361412..be6b394d1f8dc 100644 --- a/tests/utils/test_db.py +++ b/tests/utils/test_db.py @@ -96,6 +96,8 @@ def test_database_schema_and_sqlalchemy_model_are_in_sync(self): lambda t: (t[0] == "remove_table" and t[1].name == "sqlite_sequence"), # fab version table lambda t: (t[0] == "remove_table" and t[1].name == "alembic_version_fab"), + # Ignore _xcom_archive table + lambda t: (t[0] == "remove_table" and t[1].name == "_xcom_archive"), ] for ignore in ignores: