StrataFrame Forum

Deploy 1 package to multiple databases on same server

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

By Marcel Heitlager - 2/2/2010

Hi guys,



I'm trying to do the above. I've looked at the sampledatainstaller and DatabaseMigratorClass info. Still have a few questions though.

1. Is it possible to install a database to a filegroup programmatically? IOW supply the value at runtime?

2. How can I select a database to apply a profile script to that's not in the drop down? Is it possible to change that value on the fly as well?

3. If I want to do a Grant EXEC on PPMUserSecurity_Delete to SOMEID in the script for stored procedures, is it possible to pass in the SOMEID value on the fly?



Thanks
By Trent L. Taylor - 2/2/2010

Yes, this is all possible and is actually what we do with our medical application.

When you create a file group, you can use a wildcard which will change with the name provided for a database.  This is actually done by default, but this is how you can have as many different databases deployed to the same server through the same package with a different name.  You just have to supply the deployment name.  You can do this programmatically or through the standard pre-built dialogs.  To have the file group rename itself with the database name you supply at run-time, use the $DbName$ wildcard:

As for executing a profile script for a database that doesn't exist, just use the master database and then you can use your profile code to either set a database or execute on a database just as you would for any other SPROC.

By Marcel Heitlager - 2/2/2010

Funny thing happened this evening on the way to the bathroom at Subways. I was thinking, you know, that wildcard value pre-filled in that field with the instructions next to it, probably takes care of the database naming issue. I tried it out, and then looking at the xml files for the Profilescripts I noticed that it reference the Database key, not the name, so I figured I bet that takes care of that too. It did! Later I got home and thought, let me reply to my message before they respond. Arghh!! too late.



Anyway, thanks (though I can't promise that later I won't have another question if I'm nowhere near the epiphany chamber.)



However, I got a little issue now. I have two databases in one profile. I added the wildcard to the filegroup for the first database. I left the filegroup for the second database blank, because it wouldn't let me put the wildcard in it. That worked for a while, but then suddenly the name of the last database I installed appeared in the 2nd database's filegroup. When I try to give the 2nd database the same wildcard value it won't let me. Neither will it let me leave it blank. What gives? Is there a "wilcard" type of way to force both tables in same filegroup using your interface?



Marcel
By Dustin Taylor - 2/3/2010

Yep, you are right. I went in and reproduced it and we aren't accounting for wildcards when we check for duplicate physical file names.

We've corrected it, and the correction will go out with the next build.  In the mean time, the work around is to add anything to the wildcard to make it a unique name for the profile. So instead of the default "$DbName$", change the second database to "$DbName$_Standard" or anything else unique for the profile and it will allow you to save the record and deploy.