Skip to content

Commit

Permalink
add cache_is_valid property to query model
Browse files Browse the repository at this point in the history
  • Loading branch information
nattvara committed Mar 8, 2023
1 parent 70b8156 commit c7ec5d2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
20 changes: 20 additions & 0 deletions db/migrations/011_add_more_cache_is_valid_column_to_query_table.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""Peewee migrations -- 011_add_more_cache_is_valid_column_to_query_table.py."""
import peewee as pw
from peewee_migrate import Migrator

from db.models import Query


def migrate(migrator: Migrator, database: pw.Database, fake=False, **kwargs):
"""Write your migrations here."""
field = pw.BooleanField(null=False, default=True)
migrator.add_fields(
Query,
cache_is_valid=field,
)
migrator.run()


def rollback(migrator: Migrator, database: pw.Database, fake=False, **kwargs):
"""Write your rollback migrations here."""
migrator.remove_fields(Query, 'cache_is_valid', cascade=True)
1 change: 1 addition & 0 deletions db/models/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class Query(Base):
query_hash = peewee.CharField(index=True, null=False)
query_string = peewee.TextField(null=False)
count = peewee.IntegerField(null=False, default=0)
cache_is_valid = peewee.BooleanField(null=False, default=True)
response = peewee.TextField(null=True)

@staticmethod
Expand Down

0 comments on commit c7ec5d2

Please sign in to comment.