我在我的django应用程序中使用了2个postgres数据库。
'newpostgre': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'new_postgre2',
'USER': 'tester',
'PASSWORD': 'password',
'HOST': 'localhost',
'PORT': '',
},
'newpostgre2': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'new_postgre3',
'USER': 'tester',
'PASSWORD': 'password',
'HOST': 'localhost',
'PORT': '',
},我有一个非常简单的模型
class Check1(models.Model):
title = models.CharField(max_length=100)我已经跑了
python manage.py migrate --database=newpostgre
python manage.py migrate --database=newpostgre2当我在postgre中打开我的new_postgre2(用于newpostgre)数据库时,我可以在那里看到我的Check1表。
但是在postgre中我的new_postgre3(用于newpostgre2)数据库中,没有Check1表,只有那些初始迁移。
迁移成功后,为什么在new_postgre3中看不到我的表?
发布于 2017-02-27 21:31:39
因为相同的对象名称可以在不同的模式中使用,所以有时会发生冲突。最佳实践允许多个用户使用一个数据库,而不会相互干扰。使用此更改第二个数据库用户并再次检查。我想是工作吧。
'newpostgre': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'new_postgre2',
'USER': 'tester',
'PASSWORD': 'password',
'HOST': 'localhost',
'PORT': '',
},
'newpostgre2': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'new_postgre3',
'USER': 'tester_different',
'PASSWORD': 'password_different',
'HOST': 'localhost',
'PORT': '',
},python数据库迁移-- manage.py =newpostgre2
https://stackoverflow.com/questions/42486392
复制相似问题