Today, if you want to add new table fields to a tenant you will have to add this field to all tenants. Would be good if we could add specific fields only to some tenants.
Proposed solution
Hard coded of tenant specific fields schemas: A meta class attribute that receives a dict with the tenant slugs pointing to its respective specific fields schema for the model. You also would have to add the CodebaseSchemaSpecificFieldsMixin to the model class.
Client customizable tenant specific fields schemas: Creation of this two tables to store the specific fields metadata:
TenantSpecificField
- tenant: foreign key to a tenant,
- content_type: foreign key to django ContentType table
- name: char field,
- data_type: choices char field
- is_required: boolean,
- default_value: text_field,
- validators: many to many field
TenantSpecificFieldsValidator
- module_path: string
- tenants: many to many field to tenants
You would have to add the DatabaseSchemaSpecificFieldsMixin to the model class. It would add a JSONField (or TextField if JSONField is not supported by the database) in the original table where we should have the specific fields values.
Client customizable tenant specific tables: Creation of this three tables to store the specific tables and its fields metadata:
TenantSpecificTable
- tenant: foreign key to a tenant,
- name: char field,
TenantSpecificTableField
- tenant: foreign key to a tenant,
- tenant_specific_table: foreign key to TenantSpecificTable
- name: char field,
- data_type: choices char field
- is_required: boolean,
- default_value: text_field,
- validators: many to many field
TenantSpecificFieldsValidator
- module_path: string
- tenants: many to many field to tenants
Other requirements
Some helpers to validate, create and update these specific fields.
Some REST API endpoints to list/create/retrieve/update/delete TenantSpecificTable and its fields
Some REST API endpoints to list/create/retrieve/update/delete TenantSpecificField
Some generic form class to handle models with specific fields like ModelForm does
Some generic serializer class to handle models with specific fields like ModelSerializer does
A form to handle TenantSpecificTables data create/update
A serializer and view to handle TenantSpecificTables data
Description
Today, if you want to add new table fields to a tenant you will have to add this field to all tenants. Would be good if we could add specific fields only to some tenants.
Proposed solution
Client customizable tenant specific fields schemas: Creation of this two tables to store the specific fields metadata:
You would have to add the DatabaseSchemaSpecificFieldsMixin to the model class. It would add a JSONField (or TextField if JSONField is not supported by the database) in the original table where we should have the specific fields values.
Client customizable tenant specific tables: Creation of this three tables to store the specific tables and its fields metadata:
Other requirements