from models import db
from peewee import *


class Server(Model):
    id = AutoField()  # 自动递增的主键
    area_code = CharField(null=True, max_length=255, help_text='电话号码区号')  # 区号
    phone_number = CharField(null=True, max_length=255, help_text='电话号码')  # 电话号码
    device_model = CharField(null=True, max_length=255, help_text='设备型号')  # 设备型号
    system_version = CharField(null=True, max_length=255, help_text='系统版本')  # 系统版本
    app_version = CharField(null=True, max_length=255, help_text='应用版本')  # 应用版本
    lang_code = CharField(null=True, max_length=255, help_text='语言代码')  # 语言代码
    system_lang_code = CharField(null=True, max_length=255, help_text='系统语言代码')  # 系统语言代码
    start = IntegerField(null=True, help_text='Session 状态')  # Session 状态
    api_id = IntegerField(null=True, help_text='API ID')  # API ID
    api_hash = CharField(null=True, max_length=255, help_text='API Hash')  # API Hash

    class Meta:
        database = db  # 指定数据库
        table_name = 'server'  # 指定表名称
        indexes = (
            # 可根据需求添加索引，视具体情况而定
            (('area_code', 'phone_number'), False),  # 例如：为区号与电话号码添加组合索引
        )

    def __str__(self):
        return f"Server(id={self.id}, area_code={self.area_code}, phone_number={self.phone_number}, start={self.start})"


if __name__ == '__main__':
    Server.create()