forked from apache/airflow
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Notes stored in separate table (apache#27849)
* wip * try revert rename * simplify * working, minimally * more reverting of notes -> note rename * more reverting of notes -> note rename * more reverting of notes -> note rename * remove scratch code * remove test speedup * restore admin view * add migration * add migration * tod * fix migration * Add DagRunNote * add migration file * disamble notes in search * fix dagrun tests * fix some tests and tighten up relationships, i think * remove notes from create_dagrun method * more cleanup * fix collation * fix db cleanup test * more test fixup * more test fixup * rename to tinote * rename fixup * Don't import FAB user models just to define FK rel We don't (currently) define any relationships it's just for making the FK match the migration, so for now we can have the FK col defined as a string. When we eventually add a relationship to the get the creator of the note, we should move the FAB User model into airflow.models and change Security manager code to import from there instead. * Avoid touching test file unnecessarily * fix import * Apply suggestions from code review * Test that a user_id is set when creating note via api * Fix static checks Co-authored-by: Ash Berlin-Taylor <[email protected]> Co-authored-by: Jed Cunningham <[email protected]> Co-authored-by: Jed Cunningham <[email protected]>
- Loading branch information
1 parent
b18f319
commit adccc2d
Showing
23 changed files
with
1,602 additions
and
1,397 deletions.
There are no files selected for viewing
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
94 changes: 94 additions & 0 deletions
94
airflow/migrations/versions/0121_2_5_0_add_dagrunnote_and_taskinstancenote.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,94 @@ | ||
# | ||
# 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 DagRunNote and TaskInstanceNote | ||
Revision ID: 1986afd32c1b | ||
Revises: ee8d93fcc81e | ||
Create Date: 2022-11-22 21:49:05.843439 | ||
""" | ||
|
||
from __future__ import annotations | ||
|
||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
from airflow.migrations.db_types import StringID | ||
from airflow.utils.sqlalchemy import UtcDateTime | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "1986afd32c1b" | ||
down_revision = "ee8d93fcc81e" | ||
branch_labels = None | ||
depends_on = None | ||
airflow_version = "2.5.0" | ||
|
||
|
||
def upgrade(): | ||
"""Apply Add DagRunNote and TaskInstanceNote""" | ||
op.create_table( | ||
"dag_run_note", | ||
sa.Column("user_id", sa.Integer(), nullable=True), | ||
sa.Column("dag_run_id", sa.Integer(), nullable=False), | ||
sa.Column( | ||
"content", sa.String(length=1000).with_variant(sa.Text(length=1000), "mysql"), nullable=True | ||
), | ||
sa.Column("created_at", UtcDateTime(timezone=True), nullable=False), | ||
sa.Column("updated_at", UtcDateTime(timezone=True), nullable=False), | ||
sa.ForeignKeyConstraint( | ||
("dag_run_id",), ["dag_run.id"], name="dag_run_note_dr_fkey", ondelete="CASCADE" | ||
), | ||
sa.ForeignKeyConstraint(("user_id",), ["ab_user.id"], name="dag_run_note_user_fkey"), | ||
sa.PrimaryKeyConstraint("dag_run_id", name=op.f("dag_run_note_pkey")), | ||
) | ||
|
||
op.create_table( | ||
"task_instance_note", | ||
sa.Column("user_id", sa.Integer(), nullable=True), | ||
sa.Column("task_id", StringID(), nullable=False), | ||
sa.Column("dag_id", StringID(), nullable=False), | ||
sa.Column("run_id", StringID(), nullable=False), | ||
sa.Column("map_index", sa.Integer(), nullable=False), | ||
sa.Column( | ||
"content", sa.String(length=1000).with_variant(sa.Text(length=1000), "mysql"), nullable=True | ||
), | ||
sa.Column("created_at", UtcDateTime(timezone=True), nullable=False), | ||
sa.Column("updated_at", UtcDateTime(timezone=True), nullable=False), | ||
sa.PrimaryKeyConstraint( | ||
"task_id", "dag_id", "run_id", "map_index", name=op.f("task_instance_note_pkey") | ||
), | ||
sa.ForeignKeyConstraint( | ||
("dag_id", "task_id", "run_id", "map_index"), | ||
[ | ||
"task_instance.dag_id", | ||
"task_instance.task_id", | ||
"task_instance.run_id", | ||
"task_instance.map_index", | ||
], | ||
name="task_instance_note_ti_fkey", | ||
ondelete="CASCADE", | ||
), | ||
sa.ForeignKeyConstraint(("user_id",), ["ab_user.id"], name="task_instance_note_user_fkey"), | ||
) | ||
|
||
|
||
def downgrade(): | ||
"""Unapply Add DagRunNote and TaskInstanceNote""" | ||
op.drop_table("task_instance_note") | ||
op.drop_table("dag_run_note") |
63 changes: 0 additions & 63 deletions
63
airflow/migrations/versions/0121_2_5_0_add_user_comment_to_task_instance_and_dag_run.py
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.