AI ニジカ綜合
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
2.4 KiB

  1. from __future__ import annotations
  2. from eloquent import DatabaseManager, Schema
  3. CONFIG: dict[str, DbConfig] = { 'mysql': { 'driver': 'mysql',
  4. 'host': 'localhost',
  5. 'database': 'nizika_ai',
  6. 'user': os.environ['MYSQL_USER'],
  7. 'password': os.environ['MYSQL_PASS'],
  8. 'prefix': '' } }
  9. DB = DatabaseManager (CONFIG)
  10. SCHEMA = Schema (DB)
  11. def main (
  12. ) -> None:
  13. create_queries ()
  14. create_answers ()
  15. create_users ()
  16. def create_queries (
  17. ) -> None:
  18. with SCHEMA.create ('queries') as table:
  19. table.big_increments ('id')
  20. table.big_integer ('user_id').nullable ().comment ('クエリ主')
  21. table.integer ('target_character').comment ('クエリ先キャラクタ')
  22. table.text ('content').comment ('クエリ内容')
  23. table.binary ('attachment').nullable ().default (None).comment ('添附')
  24. table.integer ('query_type').comment ('クエリ区分')
  25. table.datetime ('sent_at', 6).comment ('送信日時')
  26. table.boolean ('answered').default (False).comment ('回答済')
  27. def create_answers (
  28. ) -> None:
  29. with SCHEMA.create ('answers') as table:
  30. table.big_increments ('id')
  31. table.big_integer ('query_id').nullable ().comment ('クエリ')
  32. table.integer ('character').comment ('キャラクタ区分')
  33. table.text ('content').comment ('回答内容')
  34. table.integer ('answer_type').comment ('回答区分')
  35. table.datetime ('sent_at', 6).comment ('送信日時')
  36. table.boolean ('answered').default (False).comment ('回答済')
  37. def create_users (
  38. ) -> None:
  39. with SCHEMA.create ('users') as table:
  40. table.big_increments ('id')
  41. table.integet ('platform').comment ('プラットフォーム区分')
  42. table.string ('code').nullable ().comment ('ユーザ・コード(プラットフォーム依存)')
  43. table.string ('name').comment ('ユーザ名(プラットフォーム内)')
  44. table.binary ('icon').nullable ().comment ('アイコン')
  45. class DbConfig (TypedDict):
  46. driver: str
  47. host: str
  48. database: str
  49. user: str
  50. password: str
  51. prefix: str
  52. if __name__ == '__main__':
  53. main ()