Villas I am very interested in this. I need the same thing.

One solution I have thought of consists of having many databases.
On database for registering companies and one database per each
company.

Another solution is the one you suggest. Add a 'company_id' field to
each table that defaults to a session.company_id (perhaps set from the
domain name) and use add a (db.table.company_id==session.company_id)
to each query.
You would have to alter also the table auth_group and auth_user to
make them only unique up to a company.
I have not tried this so let me know what problems you run in.

I actually encourage everything to think multi-company. If you have a
cool project you may as well post it as a service for more than one
organization.

Massimo

On Apr 29, 7:30 pm, villas <[email protected]> wrote:
> Hi All,
>
> I would like to use a single web2py app for many companies using a
> single DB.  For simplicity,  I would prefer to use just one set of
> tables too.
>
> My planned strategy is:
> 1. Define a 'company' table to have the basic company info.
> 2. Add a company_id field to all other tables to keep data separate.
> 3. Set a 'global' company_id variable when users access the app (I
> could for example set this according to the sub-domain used).
>
> I am concerned about auth.  I know that I can add the company_id field
> to auth_users,  but what about groups?  Is there any way of making
> them work?
>
> Are there any other considerations.  Maybe someone might have a few
> tips?
>
> Thanks,  D

Reply via email to