This project is read-only.

Multi-tenancy Problems

Topics: Troubleshooting
Jul 3, 2016 at 6:07 AM
What is the best way to sync a multi-tenancy setup between a production and development environment on different servers - both running 1.10.1? Currently, I have one site in production (customer A) and one in development (customer B). I tried to export the production db and media content for customer A to the development machine and then delete and import all of their tenant tables in sql (only customer A tables). This worked great at first and the customer A site loaded on the development system along with the latest content that they had added. I could also get logged in as admin, but when I tried to add or update any content to that site - I got nhibernate null id - don't flush session errors, but I could still add new content to the development site (customer B). Is there something I need to correct in the tenant settings/app_data or in the host sql table or is this setup not possible at all? Any help would be greatly appreciated!

Below is the script I used to delete the stale tables for customer A on the development machine, then I used the MS SQL Import/Export tool to import the newest tables from the production db.

SELECT @sql += '
+ '.' + QUOTENAME( + ';'
FROM sys.tables AS t
INNER JOIN sys.schemas AS s
ON t.[schema_id] = s.[schema_id] 
WHERE LIKE 'tenantNameHere%';
EXEC sp_executesql @sql;
Jul 3, 2016 at 10:57 PM
The MS SQL Import/Export Tool was importing the Identity columns and values correctly, but wasn't importing the Schema with PK, FK, constraints. I was able to fix this by using a demo of Red Gate Compare and then using the MS Import/Export tool for the data.

I found a list of similar programs that might do the job on the open source Open DBDiff page.
Marked as answer by bricklayer77 on 7/3/2016 at 2:57 PM