commit 4ecdb4f3eb40f52375aac35a2bcaa88718c75698 Author: miteruzo Date: Fri Nov 22 00:29:49 2024 +0900 #3 まづは形から diff --git a/migration.py b/migration.py new file mode 100644 index 0000000..7d12bb6 --- /dev/null +++ b/migration.py @@ -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')