2022-01-15 00:23:50 +00:00
|
|
|
import peewee
|
|
|
|
import datetime
|
|
|
|
from app.classes.models.users import Users
|
|
|
|
|
|
|
|
|
|
|
|
def migrate(migrator, db):
|
|
|
|
class ApiKeys(peewee.Model):
|
|
|
|
token_id = peewee.AutoField()
|
2022-03-23 02:50:12 +00:00
|
|
|
name = peewee.CharField(default="", unique=True, index=True)
|
2022-01-15 00:23:50 +00:00
|
|
|
created = peewee.DateTimeField(default=datetime.datetime.now)
|
2022-03-23 02:50:12 +00:00
|
|
|
user = peewee.ForeignKeyField(Users, backref="api_token", index=True)
|
|
|
|
server_permissions = peewee.CharField(default="00000000")
|
|
|
|
crafty_permissions = peewee.CharField(default="000")
|
2022-01-15 00:23:50 +00:00
|
|
|
superuser = peewee.BooleanField(default=False)
|
|
|
|
|
|
|
|
class Meta:
|
2022-03-23 02:50:12 +00:00
|
|
|
table_name = "api_keys"
|
2022-01-15 00:23:50 +00:00
|
|
|
|
|
|
|
migrator.create_table(ApiKeys)
|
|
|
|
|
|
|
|
|
|
|
|
def rollback(migrator, db):
|
2022-03-23 02:50:12 +00:00
|
|
|
migrator.drop_table("api_keys")
|