Skip to content

Commit c23a9fb

Browse files
vardancseAlice Berard
authored and
Alice Berard
committed
[AIRFLOW-2861] Add index on log table (apache#3709)
1 parent d1d5cdf commit c23a9fb

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
19+
from alembic import op
20+
21+
"""add idx_log_dag
22+
23+
Revision ID: dd25f486b8ea
24+
Revises: 9635ae0956e7
25+
Create Date: 2018-08-07 06:41:41.028249
26+
27+
"""
28+
29+
# revision identifiers, used by Alembic.
30+
revision = 'dd25f486b8ea'
31+
down_revision = '9635ae0956e7'
32+
branch_labels = None
33+
depends_on = None
34+
35+
36+
def upgrade():
37+
op.create_index('idx_log_dag', 'log', ['dag_id'], unique=False)
38+
39+
40+
def downgrade():
41+
op.drop_index('idx_log_dag', table_name='log')

airflow/models.py

+4
Original file line numberDiff line numberDiff line change
@@ -2110,6 +2110,10 @@ class Log(Base):
21102110
owner = Column(String(500))
21112111
extra = Column(Text)
21122112

2113+
__table_args__ = (
2114+
Index('idx_log_dag', dag_id),
2115+
)
2116+
21132117
def __init__(self, event, task_instance, owner=None, extra=None, **kwargs):
21142118
self.dttm = timezone.utcnow()
21152119
self.event = event

0 commit comments

Comments
 (0)