pnu-code-place / code-place

Code Place for PNU.
https://code.pusan.ac.kr
4 stars 1 forks source link

[BUGFIX] 특정 커밋 이후 migrate 에러 #6

Closed minmunui closed 8 months ago

minmunui commented 10 months ago

https://github.com/Boksam/OnlineJudge/commit/071f4751d088f2629eeec01304d513b411a7f343

위 커밋 이후로 migrate 도중 아래 버그가 발생합니다.

Operations to perform:
  Apply all migrations: account, announcement, auth, community, conf, contenttypes, contest, django_dramatiq, options, problem, sessions, submission
Running migrations:
  Applying account.0001_initial... OK
  Applying account.0002_auto_20170209_1028... OK
  Applying account.0003_userprofile_total_score... OK
  Applying account.0005_auto_20170830_1154... OK
  Applying account.0006_user_session_keys... OK
  Applying account.0008_auto_20171011_1214... OK
  Applying account.0009_auto_20171125_1514... OK
  Applying account.0010_auto_20180501_0436... OK
  Applying account.0011_auto_20180501_0456... OK
  Applying account.0012_userprofile_language... OK
  Applying account.0013_auto_20231203_0742... OK
  Applying account.0014_rename_college_name_department_college... OK
  Applying account.0015_auto_20231203_0912... OK
  Applying announcement.0001_initial... OK
  Applying announcement.0002_auto_20171011_1214... OK
  Applying announcement.0003_auto_20180501_0436... OK
  Applying contenttypes.0001_initial... OK
  Applying contenttypes.0002_remove_content_type_name... OK
  Applying auth.0001_initial... OK
  Applying auth.0002_alter_permission_name_max_length... OK
  Applying auth.0003_alter_user_email_max_length... OK
  Applying auth.0004_alter_user_username_opts... OK
  Applying auth.0005_alter_user_last_login_null... OK
  Applying auth.0006_require_contenttypes_0002... OK
  Applying auth.0007_alter_validators_add_error_messages... OK
  Applying auth.0008_alter_user_username_max_length... OK
  Applying auth.0009_alter_user_last_name_max_length... OK
  Applying auth.0010_alter_group_name_max_length... OK
  Applying auth.0011_update_proxy_permissions... OK
  Applying auth.0012_alter_user_first_name_max_length... OK
  Applying submission.0001_initial... OK
  Applying submission.0002_auto_20170509_1203... OK
  Applying submission.0005_submission_username... OK
  Applying submission.0006_auto_20170830_1154... OK
  Applying submission.0007_auto_20170923_1318...Traceback (most recent call last):
  File "/Users/minmunui/Desktop/work/OnlineJudge/development/OnlineJudge/manage.py", line 12, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/minmunui/anaconda3/lib/python3.10/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "/Users/minmunui/anaconda3/lib/python3.10/site-packages/django/core/management/__init__.py", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/minmunui/anaconda3/lib/python3.10/site-packages/django/core/management/base.py", line 354, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/Users/minmunui/anaconda3/lib/python3.10/site-packages/django/core/management/base.py", line 398, in execute
    output = self.handle(*args, **options)
  File "/Users/minmunui/anaconda3/lib/python3.10/site-packages/django/core/management/base.py", line 89, in wrapped
    res = handle_func(*args, **kwargs)
  File "/Users/minmunui/anaconda3/lib/python3.10/site-packages/django/core/management/commands/migrate.py", line 244, in handle
    post_migrate_state = executor.migrate(
  File "/Users/minmunui/anaconda3/lib/python3.10/site-packages/django/db/migrations/executor.py", line 117, in migrate
    state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
  File "/Users/minmunui/anaconda3/lib/python3.10/site-packages/django/db/migrations/executor.py", line 147, in _migrate_all_forwards
    state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
  File "/Users/minmunui/anaconda3/lib/python3.10/site-packages/django/db/migrations/executor.py", line 227, in apply_migration
    state = migration.apply(state, schema_editor)
  File "/Users/minmunui/anaconda3/lib/python3.10/site-packages/django/db/migrations/migration.py", line 126, in apply
    operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
  File "/Users/minmunui/anaconda3/lib/python3.10/site-packages/django/db/migrations/operations/fields.py", line 244, in database_forwards
    schema_editor.alter_field(from_model, from_field, to_field)
  File "/Users/minmunui/anaconda3/lib/python3.10/site-packages/django/db/backends/base/schema.py", line 581, in alter_field
    new_db_params = new_field.db_parameters(connection=self.connection)
  File "/Users/minmunui/anaconda3/lib/python3.10/site-packages/django/db/models/fields/related.py", line 1004, in db_parameters
    return {"type": self.db_type(connection), "check": self.db_check(connection)}
  File "/Users/minmunui/anaconda3/lib/python3.10/site-packages/django/db/models/fields/related.py", line 1001, in db_type
    return self.target_field.rel_db_type(connection=connection)
  File "/Users/minmunui/anaconda3/lib/python3.10/site-packages/django/db/models/fields/related.py", line 897, in target_field
    return self.foreign_related_fields[0]
  File "/Users/minmunui/anaconda3/lib/python3.10/site-packages/django/utils/functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/Users/minmunui/anaconda3/lib/python3.10/site-packages/django/db/models/fields/related.py", line 644, in foreign_related_fields
    return tuple(rhs_field for lhs_field, rhs_field in self.related_fields if rhs_field)
  File "/Users/minmunui/anaconda3/lib/python3.10/site-packages/django/utils/functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/Users/minmunui/anaconda3/lib/python3.10/site-packages/django/db/models/fields/related.py", line 632, in related_fields
    return self.resolve_related_fields()
  File "/Users/minmunui/anaconda3/lib/python3.10/site-packages/django/db/models/fields/related.py", line 936, in resolve_related_fields
    related_fields = super().resolve_related_fields()
  File "/Users/minmunui/anaconda3/lib/python3.10/site-packages/django/db/models/fields/related.py", line 615, in resolve_related_fields
    raise ValueError('Related model %r cannot be resolved' % self.remote_field.model)
ValueError: Related model 'contest.contest' cannot be resolved

재현방법

아래 명령어를 통해 db재설치

sh init_dh.sh 

위 커밋을 checkout한 상태에서 migrate

python3 manage.py makemigrations
python3 manage.py migrate
minmunui commented 10 months ago

@Boksam @hunsy9 확인 가능할까요?