[RFC] attachment_s3: improvement to use one bucket for one customer (also multi-tenancy use?)
jjscarafia opened this issue · 1 comments
We would like to make some improvements to the module. Any though?
Objetive:
For one customer (project) use only one bucket for all his databases (production, training, etc)
The main advantage I see for this approach from this recently added functionality is that we can easily (and safely) rename or changed who owns an object without needing to rename the ir.attachment.filename .
How it would work:
The idea is to use one bucket for same customer/project. Then, when deleting s3 attachments, we only wants to delete them if the attachments is owned by this database.
Modifications needed:
- when s3 objects are created we add a label 'database_name = creator_db_name'
- when calling
ir.attachment.unlink
, if s3 file ands3 bucket = actual bucket
(actual checks) anddatabase name != s3 object.label.database_name
, skip unlink - if renaming a database we should check all s3 objects and rename the label database_name for new database name
Extra functionality:
When deleting a database thought odoo drop functionality, the s3 objects are not deleted. We could also implement to delete them on s3 checking for objects where "object.label.database_name = database_name" (this could be also done outside the module, the good thing is that we know for each object witch database is the owner with the label)
Use cases
Use case 1: duplicate production database for training
- Production database is duplicated for training (or a training database is created by restoring a pg backup)
- new files are created on new training database
- user deletes attachments on training database
- only attachments created on training database are deleted (if some of the where created by production database they will remain there)
Use case 2: rename a database, for eg, and upgraded database to new odoo version become production one)
- on the upgraded databases new files are created
- the upgraded database become the production db
- if we call the rename of the database, all objects labels are renamed so that the belongs to new database
@jjscarafia I am not a big fan of having a database accessing the filestore of another. I would like to keep it clean and separated, like Odoo does by default on the filesystem. It is also what Odoo admin users expect: same behaviour as what they are used to.