Browse Source

#3 まづは形から

main
みてるぞ 1 week ago
commit
4ecdb4f3eb
1 changed files with 48 additions and 0 deletions
  1. +48
    -0
      migration.py

+ 48
- 0
migration.py View File

@@ -0,0 +1,48 @@
from eloquent.migrations import Migration


class CreateQueries (Migration):
"""
queries テーブルの作成
"""

def up (
self,
) -> None:
with self.schema.create ('queries') as table:
table.big_increments ('id')
table.big_integer ('user_id').nullable ().comment ('クエリ主')
table.integer ('target_character').comment ('クエリ先キャラクタ')
table.text ('content').comment ('クエリ内容')
table.binary ('attachment').nullable ().default (None).comment ('添附')
table.integer ('query_type').comment ('クエリ区分')
table.datetime ('sent_at', 6).comment ('送信日時')
table.boolean ('answered').default (False).comment ('回答済')

def down (
self,
) -> None:
self.schema.drop ('queries')


class CreateAnswers (Migration):
"""
answers テーブルの作成
"""

def up (
self,
) -> None:
with self.schema.create ('answers') as table:
table.big_increments ('id')
table.big_integer ('query_id').nullable ().comment ('クエリ')
table.integer ('character').comment ('キャラクタ区分')
table.text ('content').comment ('回答内容')
table.integer ('answer_type').comment ('回答区分')
table.datetime ('sent_at', 6).comment ('送信日時')
table.boolean ('answered').default (False).comment ('回答済')

def down (
self,
) -> None:
self.schema.drop ('answers')

Loading…
Cancel
Save