StrataFrame Forum

DatabaseMigratorClass - Runs changes separatelly

http://forum.strataframe.net/Topic26723.aspx

By Luiz Lima - 4/1/2010

Guys,

I´d like to run DatabaseMigratorClass inside my system, only comands related to one specific table or view.
For example:

- in form A: run profile Scripts
- in form B: run only changes for table "X", fields, Fks, etc
- in form C: run only procedures

Is that possible?
Other question: If two users process the same PKG, what will happen?

Tks

By Edhy Rijo - 4/1/2010

Hi Luiz,



I believe the only options you have are the one shown in the Database Deployment Wizard.



Keep in mind that you can run the deployment feature as many times as you want and it will only apply the changes needed. It is the same done by the SF installation setup.



I finished implementing this class 2 weeks ago and I did it this way:

1) I have a table to save the database version.

2) I have a constant in my application where I manually change the version number.

3) I have a LoggedUsers table where I keep records of all users and their logged status. I know is not 100% reliable, but unless somebody crashed the data will be reliable.

3) When opening the application, it will compare the constant value with the one in the version table and they don't match, I will check if there are not users logged in LoggedUsers, then will call the migrator class to update the database.



So far it is working fine. Hope that can help you out.
By Luiz Lima - 4/1/2010

Ed, see my comments bellow

1) I have a table to save the database version.
R: How can I get the version? Is it a DDT version?
2) I have a constant in my application where I manually change the version number.
R: Ok
3) I have a LoggedUsers table where I keep records of all users and their logged status. I know is not 100% reliable, but unless somebody crashed the data will be reliable.
R: I have this one too... Wink
4) When opening the application, it will compare the constant value with the one in the version table and they don't match, I will check if there are not users logged in LoggedUsers, then will call the migrator class to update the database.
R: This is a problem to me! I have to garantee that my system only will open if the database is ok!
Other thing is: Many users access the database remotely, and it´s so slow.....Sad
If I could upgrate DDT version in some pieces only when necessary... pretty cool!

By Edhy Rijo - 4/1/2010

Luiz, see my comments below with >>...





1) I have a table to save the database version.

R: How can I get the version? Is it a DDT version?

>> No it is not. I is just a varchar field which represents any version you want to use, then you convert that value to a Version type to be compared with the constant. The version in the DDT pkg is not being used or implemented, we don't have access to it and it looks like the SF team will not change this because they would have to uncompress the pkg file to read the version and it is not worthy.



4) When opening the application, it will compare the constant value with the one in the version table and they don't match, I will check if there are not users logged in LoggedUsers, then will call the migrator class to update the database.

R: This is a problem to me! I have to guarantee that my system only will open if the database is ok!

Other thing is: Many users access the database remotely, and it´s so slow.....Sad

If I could upgrade DDT version in some pieces only when necessary... pretty cool!


>> I understand your point, but I am not aware of you being able to update specific objects using the DDT. If this is an In-House application in which you have control of the database, you could do a Windows Service to apply the updates late at night after checking that nobody is using the database, also if you have many remote users, you could take advantage of the SF Enterprise Server, I have not used it but I am heard just good things about it from developers using it. My logic will not let anybody work on the program unless the database have been updated.



By Luiz Lima - 4/1/2010

Ed,

ES is a fantastic solution.. I´m planning to use it in next semester.
You told what I didn´t wanna hear... I have to do a Windows Service... Crazy

Tks again...

By Edhy Rijo - 4/1/2010

Luiz Lima (04/01/2010)
You told what I didn´t wanna hear... I have to do a Windows Service... Crazy




You are welcome Luiz. There are many sample in Google on how to do a Windows Service, just keep in mind that services does not have a GUI interface so you have to either email yourself and/or add windows event to the event log to let you know of what is going on.



Good luck and let us know what you decided to do.