django-tenant-schemas 不会将迁移应用到租户模式,仅 public
django-tenant-schemas wont apply migration to tenant schema, only public
我有一个使用 django-tenant-schemas 的多租户 Django 应用程序。
有一个 SiteConfig 应用程序:
settings.py:
TENANT_APPS = (
...
'siteconfig',
...
)
INSTALLED_APPS = (
...
'siteconfig',
...
)
但我对该应用的最新迁移不适用于我的租户:
$ ./manage.py migrate_schemas --shared
[standard:public] === Running migrate for schema public
[standard:public] Operations to perform:
[standard:public] Apply all migrations: account, admin, ... siteconfig, sites, socialaccount, tenant, utilities
[standard:public] Running migrations:
[standard:public] Applying siteconfig.0007_siteconfig_access_code...
[standard:public] OK
如您所见,它仅将迁移应用到 public 架构,而不是我的租户。
如果我查看我的租户,它显示那里的迁移未应用:
$ ./manage.py tenant_command showmigrations
Enter Tenant Schema ('?' to list schemas): ?
public - localhost
test - test.localhost
Enter Tenant Schema ('?' to list schemas): test
account
[X] 0001_initial
[X] 0002_email_max_length
admin
[X] 0001_initial
[X] 0002_logentry_remove_auto_add+
.
.
.
siteconfig
[X] 0001_initial
[X] 0002_auto_20200402_2201
[X] 0003_auto_20200402_2218
[X] 0004_auto_20200402_2233
[X] 0005_auto_20200403_0947
[X] 0006_auto_20200403_1528
[ ] 0007_siteconfig_access_code # <-- DIDN'T APPLY!
为什么它不适用于租户 test
我怎样才能做到这一点?
你是运行宁
manage.py migrate_schemas --shared
仅迁移 public 架构
你应该运行
manage.py migrate_schemas
我有一个使用 django-tenant-schemas 的多租户 Django 应用程序。
有一个 SiteConfig 应用程序:
settings.py:
TENANT_APPS = (
...
'siteconfig',
...
)
INSTALLED_APPS = (
...
'siteconfig',
...
)
但我对该应用的最新迁移不适用于我的租户:
$ ./manage.py migrate_schemas --shared
[standard:public] === Running migrate for schema public
[standard:public] Operations to perform:
[standard:public] Apply all migrations: account, admin, ... siteconfig, sites, socialaccount, tenant, utilities
[standard:public] Running migrations:
[standard:public] Applying siteconfig.0007_siteconfig_access_code...
[standard:public] OK
如您所见,它仅将迁移应用到 public 架构,而不是我的租户。
如果我查看我的租户,它显示那里的迁移未应用:
$ ./manage.py tenant_command showmigrations
Enter Tenant Schema ('?' to list schemas): ?
public - localhost
test - test.localhost
Enter Tenant Schema ('?' to list schemas): test
account
[X] 0001_initial
[X] 0002_email_max_length
admin
[X] 0001_initial
[X] 0002_logentry_remove_auto_add+
.
.
.
siteconfig
[X] 0001_initial
[X] 0002_auto_20200402_2201
[X] 0003_auto_20200402_2218
[X] 0004_auto_20200402_2233
[X] 0005_auto_20200403_0947
[X] 0006_auto_20200403_1528
[ ] 0007_siteconfig_access_code # <-- DIDN'T APPLY!
为什么它不适用于租户 test
我怎样才能做到这一点?
你是运行宁
manage.py migrate_schemas --shared
仅迁移 public 架构
你应该运行
manage.py migrate_schemas