Scenario
Let's say you need create a second publishing target called staging
.
Steps
You need to create an item for the new database in the content tree at the path /sitecore/system/Publishing targets
. Then in the field Target Database
, you enter the name like staging
.
Now, you need also to create a new database. You can just duplicate the web database and rename it. Example, from Sitecore_Instance_Web
to Sitecore_Instance_Staging
.
Note that you need to clear the EventQueue, PublishQueue table of the newly created database.
You need to create a patch for the newly created database. Below is an example of the patch you can used
<?xml version="1.0" encoding="UTF-8"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<databases>
<database id="staging" singleInstance="true" type="Sitecore.Data.DefaultDatabase, Sitecore.Kernel">
<param desc="name">$(id)</param>
<icon>Images/database_web.png</icon>
<securityEnabled>true</securityEnabled>
<dataProviders hint="list:AddDataProvider">
<dataProvider ref="dataProviders/main" param1="$(id)">
<disableGroup>publishing</disableGroup>
<prefetch hint="raw:AddPrefetch">
<sc.include file="/App_Config/Prefetch/Common.config" />
<sc.include file="/App_Config/Prefetch/Webdb.config" />
</prefetch>
</dataProvider>
</dataProviders>
<proxiesEnabled>false</proxiesEnabled>
<proxyDataProvider ref="proxyDataProviders/main" param1="$(id)" />
<archives hint="raw:AddArchive">
<archive name="archive" />
<archive name="recyclebin" />
</archives>
<cacheSizes hint="setting">
<data>100MB</data>
<items>50MB</items>
<paths>2500KB</paths>
<itempaths>50MB</itempaths>
<standardValues>2500KB</standardValues>
</cacheSizes>
</database>
</databases>
</sitecore>
</configuration>
You need to add the new database to the connectionString.config
as follows
<add name="staging" connectionString="user id=sa;password=Asdcxz1++;Data Source=(local),10044;Database=Sitecore_Instance_Staging"/>
Apart from the above, you need to see into the indexing strategy for the database upon a publishing. That is, you may have a custom strategy for rebuilding indexes when publishing to staging database. Example of the patch config will be as shown below
<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<contentSearch>
<indexConfigurations>
<indexUpdateStrategies>
<onStagePublishEndAsync type="Sitecore.ContentSearch.Maintenance.Strategies.OnPublishEndAsynchronousStrategy, Sitecore.ContentSearch">
<param desc="database">staging</param>
<CheckForThreshold>true</CheckForThreshold>
</onStagePublishEndAsync>
</indexUpdateStrategies>
</indexConfigurations>
</contentSearch>
</sitecore>
</configuration>
Then in your index you make use of it within the strategies
tag as shown below
<strategies hint="list:AddStrategy">
<strategy ref="contentSearch/indexConfigurations/indexUpdateStrategies/onStagePublishEndAsync" />
</strategies>