Difference between revisions of "Database Tenancies"

From Lianjapedia
Jump to: navigation, search
(Database Switcher)
Line 26: Line 26:
  
 
==Database Switcher==
 
==Database Switcher==
 
+
[[{{ns:file}}:databaseswitcher.png|800px|left|border|link={{filepath:databaseswitcher.png}}|Database Switcher]]
 +
<br clear=all>
  
 
==See Also==
 
==See Also==

Revision as of 10:28, 2 December 2021

Database tenancies provide you with the ability to deploy an App once for multiple customers/tenants but have separate databases specific to each.

They are based on the authenticated user.

The database used by an App for a user in a specified tenancy is postfixed with an "_" followed by the tenancy (domain) for the user as specified in the Users workspace.

For example, if the database for an App is 'southwind' and the user's domain is 'xyzco' then the database for that user will be

southwind_xyzco

When the user authenticates in Desktop, Web or Mobile apps the specified database will be used rather than the default database for the App.

Remember to deploy the system!sysroles table and the database for the tenancy.

Note that if the specified domain contains '.' or '@' characters these are replaced with '_' characters.

e.g. with a domain of '@lianja.com' and an App that uses the southwind database, the tenancy database would be

southwind__lianja_com

A user with the default 'public' domain will use the database as specified in the App, e.g. 'southwind'.

You can copy a complete database to another using the COPY DATABASE command in the console or from the additional commands or context menu in the Data workspace.

The usertenancy() or userdomain() functions can be used in Lianja/VFP Server Pages (.rsp) and Lianja/VFP server-side procedures to determine the current user's domain.

Database Switcher

Database Switcher


See Also

Lianja.switchDatabase(), Runtime Database, Users and Roles, Users Workspace, USERDOMAIN(), USERTENANCY()