Does SwitchServer require databases to be identical?

Questions and answers regarding general SQL and backend databases

Does SwitchServer require databases to be identical?

Postby Mark Crichton » Tue Nov 13, 2012 6:13 am

Hi I'm using databaseManager.switchServer to switch databases, but am getting an " error in relation" , which I suspect is because the tables and fields are not identical even thought the fields actually used in the application are.
Relation error is because a field does not exist in one database and does in the other
Is there a command to refresh the relations after a switch database
Thanks
Mark
Mark Crichton
DataWise Ltd - New Zealand
http://www.datawise.co.nz
User avatar
Mark Crichton
 
Posts: 109
Joined: Mon Jan 24, 2011 10:01 am
Location: Auckland, New Zealand

Re: Does SwitchServer require databases to be identical?

Postby mboegem » Tue Nov 13, 2012 1:08 pm

Hi Mark,

you shouldn't refresh the relations, but take care of your tables being in sync between the 2 databases.
when you look at the 'slave' database, there's an option to set 'clone database from'
You should do that on your production server as well.
While importing both schema's are being updated.

Currently in 6.0.7. this 'clone' function doesn't work in developer.
Casenr SVY-3223
Marc Boegem
Solutiative / JBS Group, Partner
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance Developer

Image

Partner of Tower - The most powerful Git client for Mac and Windows
User avatar
mboegem
 
Posts: 1743
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: Does SwitchServer require databases to be identical?

Postby Mark Crichton » Wed Nov 14, 2012 12:14 am

Thanks for the comments.
It is vital that the databases are able to be different as different users may require customised differences, and I definitely do not want to have make all the databases have everybody's custom fields.
I also do not want to have multiple database per customer as this complicates admin unnecessarily.
For example all customers may use the common solution, but customer A will have an additional solution for special needs, such as member/customer login.
Thanks
Mark
Mark Crichton
DataWise Ltd - New Zealand
http://www.datawise.co.nz
User avatar
Mark Crichton
 
Posts: 109
Joined: Mon Jan 24, 2011 10:01 am
Location: Auckland, New Zealand

Re: Does SwitchServer require databases to be identical?

Postby boonstrj » Wed Nov 14, 2012 10:35 am

Maybe you can do something with the solution model. For example when you switch to an database which doesn't have some relation dynamically remove it with solution model function removeRelation. Just an idee I haven't tried it.
Jeroen Boonstra
2Serve-IT

Servoy version 5.2.13/6.1.x/7.1.0
boonstrj
 
Posts: 63
Joined: Mon Jan 07, 2008 11:49 am
Location: Netherlands

Re: Does SwitchServer require databases to be identical?

Postby rgansevles » Wed Nov 14, 2012 4:15 pm

Mark,

database-switchserver is designed for identical data models.
The data model is loaded from the original db but the queries are applied on the switch-to db.
So if you have a column that is in the the original db but not in the switch-to db, the queries on it will fail.

You probably can get away with tables that exist in the original db but not in the switch-to db as long as they are never queried.

Rob
Rob Gansevles
Servoy
User avatar
rgansevles
 
Posts: 1927
Joined: Wed Nov 15, 2006 6:17 pm
Location: Amersfoort, NL

Re: Does SwitchServer require databases to be identical?

Postby Mark Crichton » Wed Nov 21, 2012 4:49 am

Hi Rob
Thanks for the confirmation. Disappointing. Maybe others have found this to be a problem.
Any idea how hard it would be to to develop code to reload the data model?
Thanks
Mark
Mark Crichton
DataWise Ltd - New Zealand
http://www.datawise.co.nz
User avatar
Mark Crichton
 
Posts: 109
Joined: Mon Jan 24, 2011 10:01 am
Location: Auckland, New Zealand

Re: Does SwitchServer require databases to be identical?

Postby ngervasi » Wed Nov 21, 2012 11:40 am

Maybe a solution would be to use a main "template" db with all the columns of all the customers and then switch to each customer db at runtime. When a customer needs a customization, let's say a new column you just need to add it to the main template db AND to the customer db. Probably you will also have to create some metadata structure to keep track of which customizations are available per customer.
If you follow this path make sure NOT to mark the customer db's as clone of the main db otherwise servoy would create the new columns in all dbs.
Nicola Gervasi
sintpro.com
SAN Partner
ngervasi
 
Posts: 1485
Joined: Tue Dec 21, 2004 12:47 pm
Location: Arezzo, Italy


Return to SQL Databases

Who is online

Users browsing this forum: No registered users and 6 guests

cron