Metadata
Database Setup
One-Time Initial Setup
Execute these 3 scripts to setup ASP.NET session state:
C:\\Base\\Repos\\InSite\\Infrastructure\\Scripts\\Database\\Session State
Setup-SessionState-1.sqlis executed in SQL Server Management StudioSetup-SessionState-2.ps1is executed on a PowerShell command promptSetup-SessionState-3.sqlis executed in SQL Server Management Studio
Using SQL Server Management Studio create a new login named IIS APPPOOL\\InSiteAppPool if it doesn't exist.
Restore Database Backup
An anonymized backup copy of the database is located here:
C:\Base\Data\Databases\Backups\Local.bak
You can use Microsoft SQL Server Management Studio to restore the database.
Alternatively, you can execute a script from PowerShell or from a Windows command prompt. See below for additional instructions.
Command Line Setup
Note: If you have already added the PowerShell profile from Local Skip this part.
PowerShell Command Prompt (Dan)
Edit your PowerShell profile so it includes an alias for the InSite Maintenance console application, and so it includes functions to restore the database from a backup, switch between master and develop databases, execute SQL upgrade scripts.
From a PowerShell command prompt, you can restore two copies of the SQL Server database backup file with this command:
Sql-Restore
To switch between master and develop copies of the database:
Sql-Switch
Windows Command Prompt (Aleksey)
Create four CMD files:
Upgrade.cmd. This command should be used to run SQL upgrade scripts
Mark.cmd. This command should be used to mark SQL upgrade scripts as executed in case the script file(s) already was applied during development.
Switch.cmd. Switch from one environment to another, for example, from dev to hotfix.
Restore.cmd. Restore the database backup.
Example of Upgrade.cmd
Where -p specifies where upgrade scripts located
Example of Mark.cmd
Example of Switch.cmd
Example of Restore.cmd
Where parameter -b points to the folder with backups. The same folder will be used to store database files. You can add parameter -c true so that the utility restores the database only in the current environment.
Database Setup
Run Sql-Restore or Restore.cmd. This will restore the database backup to both
InSite_masterandInSite_developDatabases.Run Sql-Switch or Switch.cmd to switch between develop and master databases. This will work by renaming either of the databases to
InSiteas default database and the other one fromInSiteto its original name.Make sure
InSite_developis your default database.Open a new Query in SQL Server Management Studio and run below scripts.
Run Sql-Upgrade or Upgrade.cmd to apply all the latest upgrade scripts.
Run below queries to create a default user.
Now your environment is ready.
Different scenarios of commands usages.
Scenario 1.
I just "pulled" the latest sources and need to apply all the latest scripts to my current database.
For this purpose run Sql-Upgrade.
Scenario 2.
I create some script and already applied it to the database therefore I don't want it to be run again by Sql-Upgrade.
For this purpose run Sql-Mark
Scenario 3.
Dan just provided the latest backups and I need to restore them.
For this purpose run Sql-Restore
Scenario 4.
I need to switch to hotfix for fixing some bugs.
For this purpose do the following steps:
Switch Git to hotfix branch
Run Sql-Switch. This command will rename InSite to InSite_develop and rename InSite_master to InSite
Run Sql-Upgrade to make sure that the current database has all the latest changes.
Do all the required fixes and push them to hotfix.
Run Sql-Switch to switch back to develop database. This command will rename InSite to InSite_master and rename InSite_develop to InSite
Switch Git to develop branch.
Last updated
Was this helpful?