citusdata / django-multitenant

Python/Django support for distributed multi-tenant databases like Postgres+Citus
MIT License
730 stars 118 forks source link

Removes reserved tenant_id dependency #151

Closed gurkanindibay closed 1 year ago

gurkanindibay commented 1 year ago

Currently, when we have a referenced column with the name of tenant and we want to districute our table, we are having problems since Django is creating a tenant_id column for the tenant field and when we set tenant_id field, these two columns collides and we get errors. With this development, I added two alternative methods to set tenant column; TenantMeta.tenant_field_name and TenantMeta.tenant_id. If either of one being used, there will not be collision any more

codecov[bot] commented 1 year ago

Codecov Report

Merging #151 (5ddc650) into main (bbb4810) will increase coverage by 1.96%. The diff coverage is 100.00%.

@@             Coverage Diff             @@
##             main      #151      +/-   ##
===========================================
+ Coverage   98.03%   100.00%   +1.96%     
===========================================
  Files          33        34       +1     
  Lines        1020      1078      +58     
===========================================
+ Hits         1000      1078      +78     
+ Misses         20         0      -20     
Impacted Files Coverage Δ
django_multitenant/tests/base.py 100.00% <ø> (+2.12%) :arrow_up:
...ngo_multitenant/tests/migrations/0025_data_load.py 100.00% <ø> (ø)
.../0024_business_tenant_alter_account_id_and_more.py 100.00% <100.00%> (ø)
...roduct_purchase_store_alter_account_id_and_more.py 100.00% <100.00%> (ø)
...t/tests/migrations/0027_many_to_many_distribute.py 100.00% <100.00%> (ø)
django_multitenant/tests/models.py 100.00% <100.00%> (ø)
django_multitenant/tests/test_models.py 100.00% <100.00%> (+1.90%) :arrow_up:

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more