crafty-4/app/migrations/20211120221511_api_keys.py

17 lines
461 B
Python
Raw Normal View History

2022-01-15 00:23:50 +00:00
import peewee
import datetime
def migrate(migrator, database, **kwargs):
migrator.add_columns(
"users", valid_tokens_from=peewee.DateTimeField(default=datetime.datetime.now)
)
migrator.drop_columns("users", ["api_token"])
2022-01-15 00:23:50 +00:00
def rollback(migrator, database, **kwargs):
migrator.drop_columns("users", ["valid_tokens_from"])
migrator.add_columns(
"users", api_token=peewee.CharField(default="", unique=True, index=True)
)