ephraimbuddy commented on code in PR #42913: URL: https://github.com/apache/airflow/pull/42913#discussion_r1803837171
########## airflow/migrations/versions/0039_3_0_0_add_dag_versioning.py: ########## @@ -0,0 +1,128 @@ +# +# 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 dag versioning. + +Revision ID: 2b47dc6bc8df +Revises: fb2d4922cd79 +Create Date: 2024-10-09 05:44:04.670984 + +""" + +from __future__ import annotations + +import sqlalchemy as sa +from alembic import op + +# revision identifiers, used by Alembic. +revision = "2b47dc6bc8df" +down_revision = "fb2d4922cd79" +branch_labels = None +depends_on = None +airflow_version = "3.0.0" + + +def upgrade(): + """Apply add dag versioning.""" + with op.batch_alter_table("dag", schema=None) as batch_op: + batch_op.add_column(sa.Column("version_name", sa.String(length=250), nullable=True)) + + op.create_table( + "dag_version", + sa.Column("id", sa.Integer(), nullable=False), + sa.Column("version_number", sa.Integer(), nullable=True), + sa.Column("version_name", sa.String(length=250), nullable=True), + sa.Column("dag_id", sa.String(length=250), nullable=True), + sa.Column("dag_code_id", sa.Integer(), nullable=True), + sa.Column("serialized_dag_id", sa.Integer(), nullable=True), + sa.ForeignKeyConstraint(("dag_id",), ["dag.dag_id"], name=op.f("dag_version_dag_id_fkey")), + sa.PrimaryKeyConstraint("id", name=op.f("dag_version_pkey")), Review Comment: > Is the ID the only primary key w/o considering the dag_id contained in primary key? So the ID is a global ID irrespective of the DAG linked? Yes. I don't see any issues with that, and it's more straightforward. Do you have a case where using only the ID would be an issue? -- 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]
