-
Notifications
You must be signed in to change notification settings - Fork 14.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename last_scheduler_run into last_parsed_time, and ensure it's upda…
…ted in DB (#14581) - Fix functionality last_scheduler_run was missed in the process of migrating from sync_to_db/bulk_sync_to_db to bulk_write_to_db. This issue will fail DAG.deactivate_stale_dags() method, and blocks users from checking the last schedule time of each DAG in DB - Change name last_scheduler_run to last_parsed_time, to better reflect what it does now. Migration script is added, and codebase is updated - To ensure the migration scripts can work, we have to limit the columns needed in create_dag_specific_permissions(), so migration 2c6edca13270 can work with the renamed column. Co-authored-by: Kaxil Naik <kaxilnaik@gmail.com>
- Loading branch information
Showing
5 changed files
with
86 additions
and
12 deletions.
There are no files selected for viewing
65 changes: 65 additions & 0 deletions
65
airflow/migrations/versions/2e42bb497a22_rename_last_scheduler_run_column.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# | ||
# 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. | ||
|
||
"""rename last_scheduler_run column | ||
Revision ID: 2e42bb497a22 | ||
Revises: 8646922c8a04 | ||
Create Date: 2021-03-04 19:50:38.880942 | ||
""" | ||
|
||
import sqlalchemy as sa | ||
from alembic import op | ||
from sqlalchemy.dialects import mssql | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = '2e42bb497a22' | ||
down_revision = '8646922c8a04' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
"""Apply rename last_scheduler_run column""" | ||
conn = op.get_bind() | ||
if conn.dialect.name == "mssql": | ||
with op.batch_alter_table('dag') as batch_op: | ||
batch_op.alter_column( | ||
'last_scheduler_run', new_column_name='last_parsed_time', type_=mssql.DATETIME2(precision=6) | ||
) | ||
else: | ||
with op.batch_alter_table('dag') as batch_op: | ||
batch_op.alter_column( | ||
'last_scheduler_run', new_column_name='last_parsed_time', type_=sa.TIMESTAMP(timezone=True) | ||
) | ||
|
||
|
||
def downgrade(): | ||
"""Unapply rename last_scheduler_run column""" | ||
conn = op.get_bind() | ||
if conn.dialect.name == "mssql": | ||
with op.batch_alter_table('dag') as batch_op: | ||
batch_op.alter_column( | ||
'last_parsed_time', new_column_name='last_scheduler_run', type_=mssql.DATETIME2(precision=6) | ||
) | ||
else: | ||
with op.batch_alter_table('dag') as batch_op: | ||
batch_op.alter_column( | ||
'last_parsed_time', new_column_name='last_scheduler_run', type_=sa.TIMESTAMP(timezone=True) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters