Red Gate forums :: View topic - Database Initialization
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
Deployment Manager
Deployment Manager forum

Database Initialization

Search in Deployment Manager forum
Post new topic   Reply to topic
Jump to:  
Author Message
ktersius



Joined: 07 Mar 2013
Posts: 10

PostPosted: Thu Mar 07, 2013 8:29 am    Post subject: Database Initialization Reply with quote

Hi

I need to run a script that can get the database initialized with certain data that cannot be linked as static data. What would be the best way to get this init script going and how should I use deployment manager to run it?

Also this script would only need to run once. It does not need to run if the database is already initialized. What would be the best strategy to accomplish this?

Regards
Back to top
View user's profile Send private message
Brian Donahue



Joined: 23 Aug 2004
Posts: 6674

PostPosted: Mon Mar 11, 2013 3:02 pm    Post subject: Reply with quote

Hello,

My instinct would be to simulate linking static data by editing the database package, changing redgatedatabaseinfo.xml so that tables are linked, then you could use SQL Data Compare to compare the database to a blank database with just the table definition in it for each table and save a synchronization script in the data subfolder of the package, one file for each table, save it all back in, and recreate the package.

For example, linked static data appears in the DataFileSet element of RedGateDatabaseInfo.xml, like this:
Code:

<DataFileSet>
<Count>1</Count>
<DataFile>dbo.Users_Data.sql</DataFile>
</DataFileSet>

Then if you have a file called dbo.Users_Data.sql in the Data subfolder of the package and a table schema called Users, the inserts in the Users_Data script should be run.

I haven't tried this so if you want to give it a test and let us know?
Back to top
View user's profile Send private message
chirayu



Joined: 17 Sep 2012
Posts: 60

PostPosted: Mon Mar 11, 2013 6:48 pm    Post subject: Reply with quote

Hi

You can also use Powershell scripts with Deployment Manager to initialise your database.

If there is a 'postDeploy.ps1' script in the database package that you are deploying, that script will get run post deployment. The powershell script can then poke the database to check if it's already initialised.

Links to documentation:
- Creating database packages in TeamCity or in MSBuild
- Working with database packages in Deployment Manager

Thanks!

Chirayu
_________________
Chirayu Shishodiya
Software Engineer - Deployment Manager
Red Gate
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group