jscheffl commented on code in PR #58852:
URL: https://github.com/apache/airflow/pull/58852#discussion_r2666087841


##########
airflow-core/src/airflow/migrations/versions/0097_3_2_0_add_timetable_type_to_dag_table_for_.py:
##########
@@ -0,0 +1,64 @@
+#
+# 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.
+
+"""
+add timetable_type to dag table for filtering.
+
+Revision ID: e79fc784f145
+Revises: c47f2e1ab9d4
+Create Date: 2026-01-04 14:36:04.648869
+
+"""
+
+from __future__ import annotations
+
+import sqlalchemy as sa
+from alembic import op
+
+# revision identifiers, used by Alembic.
+revision = "e79fc784f145"
+down_revision = "c47f2e1ab9d4"
+branch_labels = None
+depends_on = None
+airflow_version = "3.2.0"
+
+
+def upgrade():
+    """Apply add timetable_type to dag table for filtering."""
+    # ### commands auto generated by Alembic - please adjust! ###
+    # Step 1: Add column as nullable to allow filling existing rows
+    with op.batch_alter_table("dag", schema=None) as batch_op:
+        batch_op.add_column(sa.Column("timetable_type", sa.String(length=255)))
+
+    # Step 2: Fill existing rows with empty string (transient data, will be 
overwritten by next DAG parsing)
+    op.execute("UPDATE dag SET timetable_type = '' WHERE timetable_type IS 
NULL")
+
+    # Step 3: Make the column non-nullable
+    with op.batch_alter_table("dag", schema=None) as batch_op:
+        batch_op.alter_column("timetable_type", 
existing_type=sa.String(length=255), nullable=False)
+
+    # ### end Alembic commands ###

Review Comment:
   @ephraimbuddy But if it is defined with server_default this means the 
Database engine will always fill the default which effectively makes the field 
not required. That means if code "misses" to fill we have "bad data". Not 
really happy about this. I'd rather prefer a "fail fast and explicit" if the 
field is not filled.
   
   (In terms of votis I'd be a -0 on this, will not block the PR but do not 
like the style because raises risks in missing consistency in application 
logic. As it is just a field to filter on UI that will "just" raise minor risk 
of follow-up bugs, no major)



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