init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
67
Tools/Install/InstallOrUpdateDevSql.ps1
Normal file
67
Tools/Install/InstallOrUpdateDevSql.ps1
Normal file
|
@ -0,0 +1,67 @@
|
|||
Import-Module SQLPS -DisableNameChecking
|
||||
$commonModule = Join-Path $PSScriptRoot "Common.psm1"
|
||||
Import-Module $commonModule
|
||||
|
||||
#region Configuration
|
||||
|
||||
$sqlInstaceName = 'kretalocal'
|
||||
$databaseName = 'Kreta'
|
||||
$userName = 'kreta'
|
||||
$password = 'Porcica1.'
|
||||
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force
|
||||
$fileToRestore = Join-Path $PSScriptRoot "..\..\Kreta.DataAccess.Migrations\InitialBackup\Kreta_dev_init.bak"
|
||||
$backupPath = "c:\SqlBackupDev"
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private functions
|
||||
|
||||
function Copy-Database($targetDatabaseFile, $backupPath)
|
||||
{
|
||||
$file = Get-Item $targetDatabaseFile
|
||||
|
||||
$newLocation = Join-Path $backupPath $file.Name
|
||||
|
||||
Copy-Item $targetDatabaseFile $backupPath -Force
|
||||
|
||||
return $newLocation = Join-Path $backupPath $file.Name
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Main
|
||||
|
||||
try
|
||||
{
|
||||
Write-Host "---------------------Checking Administrator credentials--------------------------"
|
||||
$checkCredentials = CheckCredentials
|
||||
if($checkCredentials -eq $false)
|
||||
{
|
||||
exit
|
||||
}
|
||||
|
||||
Write-Host "---------------------Start Logging-----------------------------------------------"
|
||||
StartLogging
|
||||
|
||||
Write-Host "---------------------Backup Previous Database------------------------------------"
|
||||
Backup-Database $sqlInstaceName $databaseName $userName $securePassword $backupPath
|
||||
|
||||
Write-Host "---------------------Copy database backup----------------------------------------"
|
||||
$fileToRestore = Copy-Database $fileToRestore $backupPath
|
||||
|
||||
Write-Host "---------------------Drop Previous Database--------------------------------------"
|
||||
Drop-Database $sqlInstaceName $databaseName $userName $securePassword
|
||||
|
||||
Write-Host "---------------------Restore New Database----------------------------------------"
|
||||
Restore-Database $sqlInstaceName $databaseName $userName $securePassword $fileToRestore
|
||||
|
||||
Write-Host "---------------------Reset Environment-------------------------------------------"
|
||||
ResetEnvironment
|
||||
}
|
||||
finally
|
||||
{
|
||||
Write-Host "---------------------Stop Logging------------------------------------------------"
|
||||
StopLogging
|
||||
}
|
||||
|
||||
#endregion
|
Loading…
Add table
Add a link
Reference in a new issue