作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
机器: docker 1GB
当我在已经部署的manage.py migrations
中尝试captain-definition
(成功完成makemigrations之后)时,出现此错误,
可能是因为迁移未在我的git repo中同步,并且django无法检测到没有migrations
文件夹的迁移已应用于数据库
鸭子队长鸭子队长似乎破坏了我的docker conatiner中对文件系统的任何更改,因此重新启动后migrations文件夹不可用。
System check identified some issues:
WARNINGS:
Users.CustomUser: (auth.W004) 'CustomUser.phone_number' is named as the 'USERNAME_FIELD', but it is not unique.
HINT: Ensure that your authentication backend(s) can handle non-unique usernames.
Operations to perform:
Apply all migrations: Exams, Users, account, admin, auth, contenttypes, sessions, sites, socialaccount
Running migrations:
Applying Exams.0002_auto_20180309_1911...Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute
return self.cursor.execute(sql, params)
psycopg2.ProgrammingError: column "owner_id" of relation "Exams_topic" already exists
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.6/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.6/site-packages/django/core/management/__init__.py", line 365, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python3.6/site-packages/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python3.6/site-packages/django/core/management/base.py", line 335, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 200, in handle
fake_initial=fake_initial,
File "/usr/local/lib/python3.6/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 "/usr/local/lib/python3.6/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 "/usr/local/lib/python3.6/site-packages/django/db/migrations/executor.py", line 244, in apply_migration
state = migration.apply(state, schema_editor)
File "/usr/local/lib/python3.6/site-packages/django/db/migrations/migration.py", line 122, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
File "/usr/local/lib/python3.6/site-packages/django/db/migrations/operations/fields.py", line 84, in database_forwards
field,
File "/usr/local/lib/python3.6/site-packages/django/db/backends/base/schema.py", line 421, in add_field
self.execute(sql, params)
File "/usr/local/lib/python3.6/site-packages/django/db/backends/base/schema.py", line 117, in execute
cursor.execute(sql, params)
File "/usr/local/lib/python3.6/site-packages/django/db/backends/utils.py", line 68, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "/usr/local/lib/python3.6/site-packages/django/db/backends/utils.py", line 77, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/usr/local/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python3.6/site-packages/django/db/utils.py", line 89, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/usr/local/lib/python3.6/site-packages/django/db/backends/utils.py", line 85, in _execute
return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: column "owner_id" of relation "Exams_topic" already exists
{
"schemaVersion": 1,
"dockerfileLines": [
"FROM library/python:3.6.4-jessie",
"RUN apt-get update && apt-get install -y binutils libproj-dev gdal-bin",
"RUN mkdir -p /usr/src/app",
"WORKDIR /usr/src/app",
"RUN pip install pipenv --upgrade",
"COPY ./src /usr/src/app",
"RUN pipenv install --deploy --system",
"EXPOSE 80",
"COPY ./src/runserver.sh /usr/local/bin/",
"CMD [\"sh\", \"runserver.sh\"]"
]
}
#!/bin/sh
python manage.py collectstatic --noinput
python manage.py makemigrations <appname>
python mange.py migrate
gunicorn quiz.wsgi --bind=0.0.0.0:80
最佳答案
正如Mazel Tov所建议的那样,解决方案是将您的迁移推送到GIT存储库。
进一步来说,
makemigrations <app_name>
migrate
。 关于django - 如何使用Duck Duck船长处理Django数据库迁移?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49209403/
我正在使用 sails 0.10.5,它使用 skipper 进行文件上传。现在我有一个用户可以上传文件的表单。但是,文件上传不是强制性的。在后端,我需要检查文件是否已上传。 我的代码是这样的: if
我正在使用 sails 版本 0.11,它与 skipper 捆绑在一起用于文件上传。我至少需要上传超过 100 MB 的大文件。 现在我不希望在服务器上开始进一步处理文件之前完成文件上传。我想在上传
我是一名优秀的程序员,十分优秀!