mirror of
https://github.com/flibusta-apps/services_manager_server.git
synced 2025-12-06 04:25:38 +01:00
Add cache field
This commit is contained in:
30
src/app/alembic/versions/85ece6cfed22_.py
Normal file
30
src/app/alembic/versions/85ece6cfed22_.py
Normal file
@@ -0,0 +1,30 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 85ece6cfed22
|
||||
Revises: 738a796c3f0a
|
||||
Create Date: 2021-12-27 23:08:26.124204
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '85ece6cfed22'
|
||||
down_revision = '738a796c3f0a'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('services', sa.Column('cache', sa.String(length=12), nullable=True))
|
||||
op.drop_column('services', 'privileged')
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('services', sa.Column('privileged', sa.BOOLEAN(), server_default=sa.text('false'), autoincrement=False, nullable=False))
|
||||
op.drop_column('services', 'cache')
|
||||
# ### end Alembic commands ###
|
||||
@@ -17,6 +17,12 @@ class Statuses(str, Enum):
|
||||
blocked = "blocked"
|
||||
|
||||
|
||||
class CachePrivileges(str, Enum):
|
||||
original = "original"
|
||||
buffer = "buffer"
|
||||
no_cache = "no_cache"
|
||||
|
||||
|
||||
class Service(ormar.Model):
|
||||
class Meta(BaseMeta):
|
||||
tablename = "services"
|
||||
@@ -25,5 +31,5 @@ class Service(ormar.Model):
|
||||
token: str = ormar.String(max_length=128, unique=True) # type: ignore
|
||||
user: int = ormar.BigInteger() # type: ignore
|
||||
status: str = ormar.String(max_length=12, choices=list(Statuses), default=Statuses.pending) # type: ignore
|
||||
privileged: bool = ormar.Boolean(default=False, server_default='f', nullable=False) # type: ignore
|
||||
cache: str = ormar.String(max_length=12, choices=list(CachePrivileges), default=CachePrivileges.no_cache) # type: ignore
|
||||
created_time = ormar.DateTime(timezone=True, default=datetime.now)
|
||||
|
||||
@@ -2,13 +2,14 @@ from datetime import datetime
|
||||
|
||||
from pydantic import BaseModel, constr
|
||||
|
||||
from app.models import Statuses
|
||||
from app.models import Statuses, CachePrivileges
|
||||
|
||||
|
||||
class ServiceCreate(BaseModel):
|
||||
token: constr(max_length=128) # type: ignore
|
||||
user: str
|
||||
status: Statuses
|
||||
cache: CachePrivileges
|
||||
|
||||
|
||||
class ServiceDetail(BaseModel):
|
||||
@@ -16,5 +17,5 @@ class ServiceDetail(BaseModel):
|
||||
token: str
|
||||
user: str
|
||||
status: str
|
||||
privileged: bool
|
||||
cache: str
|
||||
created_time: datetime
|
||||
|
||||
Reference in New Issue
Block a user