다른 사람이 장고 마이그레이션으로 인해 불만을 느끼고 있는지 궁금합니다. 나는 SO 관련 게시물을 여러 번 살펴 봤지만이 문제를 특별히 해결하지 못했습니다.신선한 데이터베이스로 장고 마이그레이션이 실패했습니다.
이것은 나에게도 계속 발생하며 일반적인 시나리오 여야합니다. 그래서 무엇이 누락 되었습니까?
내 시나리오 :
- 목록 항목 내 로컬 컴퓨터에 SQLite는 사용하여 반복
- 내가 지금 생산에 PostgreSQL을 데시벨 (AWS 또는 다른 곳에 배포 할, 장고 응용 프로그램을 구축 한
- )
- 새 데이터베이스를 설정하여 설정에 추가하고 실행하십시오.
python manage.py migrate
- 내 모델 테이블 중 하나가 존재하지 않는다는 SQL 오류가 발생합니다. 이런! 이것이 내가 마이그레이션을 실행하는 이유입니다. 내가 무엇을해야합니까 -
- 나는
simple_history
나는 명백한 대답이 있어야 확신처럼 패키지와 더 문제를 만들어 python manage.py migrate <app_name> --fake
같은 이상한 일을, 테이블을 손으로 만들 필요 결국 아주 깨끗한 데이터베이스에 데이터베이스 스키마를 설정 하시겠습니까? 나는 빈 데이터베이스에 python manage.py migrate
을 실행하면
, 나는 다음과 같은 오류가 발생합니다 : :
편집 : 오류가 난 점점 오전의 역 추적은
(banzai-platform-django) ➜ src git:(master) ✗ ./manage.py migrate
Traceback (most recent call last):
File "/Users/joedavy/Dropbox/Apps/banzai-platform-django/lib/python3.6/site-packages/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
psycopg2.ProgrammingError: relation "events_event" does not exist
LINE 1: ...ents_event"."created", "events_event"."slug" FROM "events_ev...
^
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "./manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/Users/joedavy/Dropbox/Apps/banzai-platform-django/lib/python3.6/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_line
utility.execute()
File "/Users/joedavy/Dropbox/Apps/banzai-platform-django/lib/python3.6/site-packages/django/core/management/__init__.py", line 355, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/joedavy/Dropbox/Apps/banzai-platform-django/lib/python3.6/site-packages/django/core/management/base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "/Users/joedavy/Dropbox/Apps/banzai-platform-django/lib/python3.6/site-packages/django/core/management/base.py", line 327, in execute
self.check()
File "/Users/joedavy/Dropbox/Apps/banzai-platform-django/lib/python3.6/site-packages/django/core/management/base.py", line 359, in check
include_deployment_checks=include_deployment_checks,
File "/Users/joedavy/Dropbox/Apps/banzai-platform-django/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 62, in _run_checks
issues.extend(super(Command, self)._run_checks(**kwargs))
File "/Users/joedavy/Dropbox/Apps/banzai-platform-django/lib/python3.6/site-packages/django/core/management/base.py", line 346, in _run_checks
return checks.run_checks(**kwargs)
File "/Users/joedavy/Dropbox/Apps/banzai-platform-django/lib/python3.6/site-packages/django/core/checks/registry.py", line 81, in run_checks
new_errors = check(app_configs=app_configs)
File "/Users/joedavy/Dropbox/Apps/banzai-platform-django/lib/python3.6/site-packages/django/core/checks/urls.py", line 16, in check_url_config
return check_resolver(resolver)
File "/Users/joedavy/Dropbox/Apps/banzai-platform-django/lib/python3.6/site-packages/django/core/checks/urls.py", line 26, in check_resolver
return check_method()
File "/Users/joedavy/Dropbox/Apps/banzai-platform-django/lib/python3.6/site-packages/django/urls/resolvers.py", line 254, in check
for pattern in self.url_patterns:
File "/Users/joedavy/Dropbox/Apps/banzai-platform-django/lib/python3.6/site-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/Users/joedavy/Dropbox/Apps/banzai-platform-django/lib/python3.6/site-packages/django/urls/resolvers.py", line 405, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/Users/joedavy/Dropbox/Apps/banzai-platform-django/lib/python3.6/site-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/Users/joedavy/Dropbox/Apps/banzai-platform-django/lib/python3.6/site-packages/django/urls/resolvers.py", line 398, in urlconf_module
return import_module(self.urlconf_name)
File "/Users/joedavy/Dropbox/Apps/banzai-platform-django/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 978, in _gcd_import
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
File "/Users/joedavy/Dropbox/Apps/banzai-platform-django/src/banzai_platform/urls.py", line 67, in <module>
url(r'^registrations/', include('registrations.urls')),
File "/Users/joedavy/Dropbox/Apps/banzai-platform-django/lib/python3.6/site-packages/django/conf/urls/__init__.py", line 50, in include
urlconf_module = import_module(urlconf_module)
File "/Users/joedavy/Dropbox/Apps/banzai-platform-django/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 978, in _gcd_import
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
File "/Users/joedavy/Dropbox/Apps/banzai-platform-django/src/registrations/urls.py", line 3, in <module>
from .views import (
File "/Users/joedavy/Dropbox/Apps/banzai-platform-django/src/registrations/views.py", line 160, in <module>
class ConfirmEventListView(ListView):
File "/Users/joedavy/Dropbox/Apps/banzai-platform-django/src/registrations/views.py", line 164, in ConfirmEventListView
queryset = [obj for obj in events if obj.need_confirmation > 0]
File "/Users/joedavy/Dropbox/Apps/banzai-platform-django/lib/python3.6/site-packages/django/db/models/query.py", line 250, in __iter__
self._fetch_all()
File "/Users/joedavy/Dropbox/Apps/banzai-platform-django/lib/python3.6/site-packages/django/db/models/query.py", line 1118, in _fetch_all
self._result_cache = list(self._iterable_class(self))
File "/Users/joedavy/Dropbox/Apps/banzai-platform-django/lib/python3.6/site-packages/django/db/models/query.py", line 53, in __iter__
results = compiler.execute_sql(chunked_fetch=self.chunked_fetch)
File "/Users/joedavy/Dropbox/Apps/banzai-platform-django/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 894, in execute_sql
raise original_exception
File "/Users/joedavy/Dropbox/Apps/banzai-platform-django/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 884, in execute_sql
cursor.execute(sql, params)
File "/Users/joedavy/Dropbox/Apps/banzai-platform-django/lib/python3.6/site-packages/django/db/backends/utils.py", line 80, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/Users/joedavy/Dropbox/Apps/banzai-platform-django/lib/python3.6/site-packages/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
File "/Users/joedavy/Dropbox/Apps/banzai-platform-django/lib/python3.6/site-packages/django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/Users/joedavy/Dropbox/Apps/banzai-platform-django/lib/python3.6/site-packages/django/utils/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/Users/joedavy/Dropbox/Apps/banzai-platform-django/lib/python3.6/site-packages/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: relation "events_event" does not exist
LINE 1: ...ents_event"."created", "events_event"."slug" FROM "events_ev...
배포 할 때 makemigrations를 실행하지 않아야합니다. 당신이 개발할 때 당신은 makemigrations를 실행합니다. –
그러나 오류가 발생하면 전체 추적과 함께 * 게시해야합니다. –
@DanielRoseman - 분명히하기 위해 나의 첫 번째 생각은 manage.py migrate를 실행하는 것이지만 동일한 오류가 발생합니다. 나는 오류 + 추적을 도움이되는 경우 게시물에 추가했습니다. –