| 
				
				
				
				 | 
			
			 | 
			@@ -1,5 +1,8 @@ | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			from __future__ import annotations | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			
  | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			import os | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			from typing import TypedDict | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			
  | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			from eloquent import DatabaseManager, Schema | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			
  | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			CONFIG: dict[str, DbConfig] = { 'mysql': { 'driver':    'mysql', | 
		
		
	
	
		
			
				| 
				
					
				
				
					
				
				
				 | 
			
			 | 
			@@ -26,9 +29,10 @@ def create_queries ( | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        table.big_integer ('user_id').nullable ().comment ('クエリ主') | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        table.integer ('target_character').comment ('クエリ先キャラクタ') | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        table.text ('content').comment ('クエリ内容') | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        table.binary ('attachment').nullable ().default (None).comment ('添附') | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        table.string ('image_url').nullable ().default (None).comment ('添附画像 URL') | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        table.integer ('query_type').comment ('クエリ区分') | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        table.datetime ('sent_at', 6).comment ('送信日時') | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        table.integer ('model').comment ('GPT のモデル') | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        table.datetime ('sent_at').comment ('送信日時') | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        table.boolean ('answered').default (False).comment ('回答済') | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			
  | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			
  | 
		
		
	
	
		
			
				| 
				
				
				
					
				
				 | 
			
			 | 
			@@ -40,7 +44,7 @@ def create_answers ( | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        table.integer ('character').comment ('キャラクタ区分') | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        table.text ('content').comment ('回答内容') | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        table.integer ('answer_type').comment ('回答区分') | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        table.datetime ('sent_at', 6).comment ('送信日時') | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        table.datetime ('sent_at').comment ('送信日時') | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        table.boolean ('answered').default (False).comment ('回答済') | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			
  | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			
  | 
		
		
	
	
		
			
				| 
				
				
				
					
				
				 | 
			
			 | 
			@@ -49,11 +53,19 @@ def create_users ( | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    with SCHEMA.create ('users') as table: | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        table.big_increments ('id') | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        table.integet ('platform').comment ('プラットフォーム区分') | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        table.string ('code').nullable ().comment ('ユーザ・コード(プラットフォーム依存)') | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        table.string ('code').comment ('ユーザ・コード(プラットフォーム依存)') | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        table.string ('name').comment ('ユーザ名(プラットフォーム内)') | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        table.binary ('icon').nullable ().comment ('アイコン') | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			
  | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			
  | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			def create_query_answer_histories ( | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			) -> None: | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    with SCHEMA.create ('query_answer_histories') as table: | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        table.big_increments ('id') | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        table.big_integer ('query_id') | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			        table.big_integer ('answer_id') | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			
  | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			
  | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			class DbConfig (TypedDict): | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    driver:     str | 
		
		
	
		
			
			 | 
			 | 
			
			 | 
			    host:       str | 
		
		
	
	
		
			
				| 
				
					
				
				
				
				 | 
			
			 | 
			
  |