You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by as...@apache.org on 2022/04/19 18:01:44 UTC

[airflow] branch main updated: Add migration to update DAG default_view (#23091)

This is an automated email from the ASF dual-hosted git repository.

ash pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new b8bbfd4b31 Add migration to update DAG default_view (#23091)
b8bbfd4b31 is described below

commit b8bbfd4b318108b4fdadc78cd46fd1735da243ae
Author: Ash Berlin-Taylor <as...@apache.org>
AuthorDate: Tue Apr 19 19:01:36 2022 +0100

    Add migration to update DAG default_view (#23091)
    
    The scheduler would make this change anyway when it next parses the dag,
    but up until that point the webserver won't be able to display the home
    page with that dag visible.
    
    This migration also helps with the new downgrade feature.
---
 .../0108_b1b348e02d07_default_dag_view_grid.py     | 55 ++++++++++++++++++++++
 docs/apache-airflow/migrations-ref.rst             |  4 +-
 2 files changed, 58 insertions(+), 1 deletion(-)

diff --git a/airflow/migrations/versions/0108_b1b348e02d07_default_dag_view_grid.py b/airflow/migrations/versions/0108_b1b348e02d07_default_dag_view_grid.py
new file mode 100644
index 0000000000..03a9f43c3a
--- /dev/null
+++ b/airflow/migrations/versions/0108_b1b348e02d07_default_dag_view_grid.py
@@ -0,0 +1,55 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Update dag.default_view to grid
+
+Revision ID: b1b348e02d07
+Revises: 75d5ed6c2b43
+Create Date: 2022-04-19 17:25:00.872220
+
+"""
+
+from alembic import op
+from sqlalchemy import String
+from sqlalchemy.sql import column, table
+
+# revision identifiers, used by Alembic.
+revision = 'b1b348e02d07'
+down_revision = '75d5ed6c2b43'
+branch_labels = None
+depends_on = '75d5ed6c2b43'
+airflow_version = '2.3.0'
+
+
+dag = table('dag', column('default_view', String))
+
+
+def upgrade():
+    op.execute(
+        dag.update()
+        .where(dag.c.default_view == op.inline_literal('tree'))
+        .values({'default_view': op.inline_literal('grid')})
+    )
+
+
+def downgrade():
+    op.execute(
+        dag.update()
+        .where(dag.c.default_view == op.inline_literal('grid'))
+        .values({'default_view': op.inline_literal('tree')})
+    )
diff --git a/docs/apache-airflow/migrations-ref.rst b/docs/apache-airflow/migrations-ref.rst
index c5a8a5caa6..88a1f84b6c 100644
--- a/docs/apache-airflow/migrations-ref.rst
+++ b/docs/apache-airflow/migrations-ref.rst
@@ -25,7 +25,9 @@ Here's the list of all the Database Migrations that are executed via when you ru
  .. Beginning of auto-generated table
 
 +---------------------------------+-------------------+-------------+--------------------------------------------------------------+
-| ``75d5ed6c2b43`` (head)         | ``909884dea523``  | ``2.3.0``   | Add map_index to Log.                                        |
+| ``b1b348e02d07`` (head)         | ``75d5ed6c2b43``  | ``2.3.0``   | Update dag.default_view to grid                              |
++---------------------------------+-------------------+-------------+--------------------------------------------------------------+
+| ``75d5ed6c2b43``                | ``909884dea523``  | ``2.3.0``   | Add map_index to Log.                                        |
 +---------------------------------+-------------------+-------------+--------------------------------------------------------------+
 | ``909884dea523``                | ``48925b2719cb``  | ``2.3.0``   | Update migration for FAB tables to add missing constraints   |
 +---------------------------------+-------------------+-------------+--------------------------------------------------------------+