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.

35 lines
936 B

  1. from __future__ import annotations
  2. from config import CONFIG
  3. from eloquent import DatabaseManager, Schema
  4. DB = DatabaseManager (CONFIG)
  5. SCHEMA = Schema (DB)
  6. def main (
  7. ) -> None:
  8. create_answered_flags ()
  9. drop_answered_column_in_answers ()
  10. def create_answered_flags (
  11. ) -> None:
  12. with SCHEMA.create ('answered_flags') as table:
  13. table.big_increments ('id')
  14. table.unsigned_big_integer ('answer_id').comment ('回答')
  15. table.integer ('platform').comment ('プラットフォーム区分')
  16. table.boolean ('answered').default (False).comment ('回答済')
  17. table.unique (['answer_id', 'platform'])
  18. table.foreign ('answer_id').references ('id').on ('answers').on_update ('cascade').on_delete ('cascade')
  19. def drop_answered_column_in_answers (
  20. ) -> None:
  21. with SCHEMA.table ('answers') as table:
  22. table.drop_column ('answered')
  23. if __name__ == '__main__':
  24. main ()