Traceback (most recent call last): File “/home/NBSystem/manage.py”, line 22, in <module> main() File “/home/NBSystem/manage.py”, line 18, in main execute_from_command_line(sys.argv) File “/usr/local/lib/python3.10/dist-packages/django/core/management/__init__.py”, line 442, in execute_from_command_line utility.execute() File “/usr/local/lib/python3.10/dist-packages/django/core/management/__init__.py”, line 436, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File “/usr/local/lib/python3.10/dist-packages/django/core/management/base.py”, line 413, in run_from_argv self.execute(*args, **cmd_options) File “/usr/local/lib/python3.10/dist-packages/django/core/management/base.py”, line 459, in execute output = self.handle(*args, **options) File “/usr/local/lib/python3.10/dist-packages/django/core/management/base.py”, line 107, in wrapper res = handle_func(*args, **kwargs) File “/usr/local/lib/python3.10/dist-packages/django/core/management/commands/migrate.py”, line 356, in handle post_migrate_state = executor.migrate( File “/usr/local/lib/python3.10/dist-packages/django/db/migrations/executor.py”, line 135, in migrate state = self._migrate_all_forwards( File “/usr/local/lib/python3.10/dist-packages/django/db/migrations/executor.py”, line 167, in _migrate_all_forwards state = self.apply_migration( File “/usr/local/lib/python3.10/dist-packages/django/db/migrations/executor.py”, line 252, in apply_migration state = migration.apply(state, schema_editor) File “/usr/local/lib/python3.10/dist-packages/django/db/migrations/migration.py”, line 132, in apply operation.database_forwards( File “/usr/local/lib/python3.10/dist-packages/django/db/migrations/operations/fields.py”, line 235, in database_forwards schema_editor.alter_field(from_model, from_field, to_field) File “/usr/local/lib/python3.10/dist-packages/django/db/backends/base/schema.py”, line 880, in alter_field self._alter_field( File “/usr/local/lib/python3.10/dist-packages/django/db/backends/base/schema.py”, line 1137, in _alter_field self.execute( File “/usr/local/lib/python3.10/dist-packages/django/db/backends/base/schema.py”, line 201, in execute cursor.execute(sql, params) File “/usr/local/lib/python3.10/dist-packages/django/db/backends/utils.py”, line 122, in execute return super().execute(sql, params) File “/usr/local/lib/python3.10/dist-packages/django/db/backends/utils.py”, line 79, in execute return self._execute_with_wrappers( File “/usr/local/lib/python3.10/dist-packages/django/db/backends/utils.py”, line 92, in _execute_with_wrappers return executor(sql, params, many, context) File “/usr/local/lib/python3.10/dist-packages/django/db/backends/utils.py”, line 100, in _execute with self.db.wrap_database_errors: File “/usr/local/lib/python3.10/dist-packages/django/db/utils.py”, line 91, in __exit__ raise dj_exc_value.with_traceback(traceback) from exc_value File “/usr/local/lib/python3.10/dist-packages/django/db/backends/utils.py”, line 105, in _execute return self.cursor.execute(sql, params) File “/usr/local/lib/python3.10/dist-packages/django/db/backends/mysql/base.py”, line 76, in execute return self.cursor.execute(query, args) File “/usr/local/lib/python3.10/dist-packages/MySQLdb/cursors.py”, line 179, in execute res = self._query(mogrified_query) File “/usr/local/lib/python3.10/dist-packages/MySQLdb/cursors.py”, line 330, in _query db.query(q) File “/usr/local/lib/python3.10/dist-packages/MySQLdb/connections.py”, line 261, in query _mysql.connection.query(self, query) django.db.utils.OperationalError: (1118, ‘Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs’)

これは、行サイズが大きすぎてMySQLが処理できないために発生しています。特に、テーブルに大量のTEXT型またはBLOB型の列が含まれている場合によく発生します。

この問題を解決するためには、いくつかの方法があります。

  1. 列のサイズを縮小する: テキスト列やBLOB列のサイズを必要最小限に抑えることで、行のサイズを減らすことができます。例えば、CharFieldの代わりにTextFieldを使用するなどの方法があります。

  2. テーブルの分割: テーブルを複数のテーブルに分割することで、1つのテーブルのサイズを小さくすることができます。関連するデータを複数のテーブルに分割して、それらを結合することができます。

  3. テーブルのエンジンを変更する: InnoDBの代わりに、MyISAMエンジンを使用することもできます。ただし、MyISAMエンジンはトランザクションのサポートが不十分であるため、これには注意が必要です。

  4. MySQLの設定を変更する: MySQLの設定ファイル (my.cnf) を編集して、行の最大サイズを拡張することもできます。ただし、これは十分なリソースがある場合にのみ推奨されます。

選択した方法は、プロジェクトのニーズや要件に応じて異なります。データベース設計を検討し、最適な解決策を見つけることが重要です。

未分類

Posted by ぼっち