Skip to content

Commit

Permalink
1 index instead of 2.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bogdan Kyryliuk committed Aug 19, 2016
1 parent 8e06087 commit e8a1a9a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
5 changes: 2 additions & 3 deletions caravel/migrations/versions/ad82a75afd82_add_query_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,9 @@ def upgrade():
)
op.add_column('dbs', sa.Column('select_as_create_table_as', sa.Boolean(),
nullable=True))
op.create_index(op.f('ix_query_changed_on'), 'query', ['changed_on'],
unique=False)
op.create_index(
op.f('ix_query_user_id'), 'query', ['user_id'], unique=False)
op.f('ti_user_id_changed_on'),
'query', ['user_id', 'changed_on'], unique=False)


def downgrade():
Expand Down
9 changes: 6 additions & 3 deletions caravel/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1769,7 +1769,7 @@ class Query(Model):
# Store the tmp table into the DB only if the user asks for it.
tmp_table_name = Column(String(256))
user_id = Column(
Integer, ForeignKey('ab_user.id'), nullable=True, index=True)
Integer, ForeignKey('ab_user.id'), nullable=True)

# models.QueryStatus
status = Column(String(16))
Expand All @@ -1796,8 +1796,11 @@ class Query(Model):
start_time = Column(DateTime)
end_time = Column(DateTime)
changed_on = Column(
DateTime, default=datetime.now, onupdate=datetime.now, nullable=True,
index=True)
DateTime, default=datetime.now, onupdate=datetime.now, nullable=True)

__table_args__ = (
sqla.Index('ti_user_id_changed_on', user_id, changed_on),
)

def to_dict(self):
return {
Expand Down

0 comments on commit e8a1a9a

Please sign in to comment.