mirror of
https://github.com/flibusta-apps/users_settings_server.git
synced 2025-12-08 09:30:41 +01:00
Init
This commit is contained in:
32
src/app/models.py
Normal file
32
src/app/models.py
Normal file
@@ -0,0 +1,32 @@
|
||||
import ormar
|
||||
|
||||
from core.db import metadata, database
|
||||
|
||||
|
||||
class BaseMeta(ormar.ModelMeta):
|
||||
metadata = metadata
|
||||
database = database
|
||||
|
||||
|
||||
class Language(ormar.Model):
|
||||
class Meta(BaseMeta):
|
||||
tablename = "languages"
|
||||
|
||||
id: int = ormar.Integer(primary_key=True) # type: ignore
|
||||
label: str = ormar.String(max_length=16) # type: ignore
|
||||
code: str = ormar.String(max_length=4, unique=True) # type: ignore
|
||||
|
||||
|
||||
class User(ormar.Model):
|
||||
class Meta(BaseMeta):
|
||||
tablename = "user_settings"
|
||||
|
||||
id: int = ormar.Integer(primary_key=True) # type: ignore
|
||||
|
||||
user_id: int = ormar.BigInteger(unique=True) # type: ignore
|
||||
last_name: str = ormar.String(max_length=64) # type: ignore
|
||||
first_name: str = ormar.String(max_length=64) # type: ignore
|
||||
username: str = ormar.String(max_length=32) # type: ignore
|
||||
source: str = ormar.String(max_length=32) # type: ignore
|
||||
|
||||
allowed_langs = ormar.ManyToMany(Language)
|
||||
Reference in New Issue
Block a user