40 lines
1.3 KiB
PowerShell
40 lines
1.3 KiB
PowerShell
# Define the path to your application's root directory
|
|
$applicationRoot = "C:\Users\santh\OneDrive\Desktop\DOCKERS\ubuntu\Sprint6\C1011\Backend-API-Services\DamageAssesmentApi\"
|
|
#To execute: powershell -ExecutionPolicy Bypass -File .\migrate-sqldb.ps1
|
|
# Define the list of microservice directories
|
|
$microservices = @(
|
|
"DamageAssesment.Api.Answers",
|
|
"DamageAssesment.Api.Attachments",
|
|
"DamageAssesment.Api.DocuLinks",
|
|
"DamageAssesment.Api.Employees",
|
|
"DamageAssesment.Api.Locations",
|
|
"DamageAssesment.Api.Questions",
|
|
"DamageAssesment.Api.Responses",
|
|
"DamageAssesment.Api.Surveys"
|
|
)
|
|
|
|
|
|
# Define the migration name with the current date and time
|
|
$migrationName = "Migration_" + (Get-Date -Format "yyyyMMdd_HHmmss")
|
|
|
|
# Function to run migrations for a microservice
|
|
Function Run-Migrations {
|
|
param (
|
|
[string]$microservicePath
|
|
)
|
|
|
|
Write-Host "Running Migrations for $microservicePath..."
|
|
Set-Location -Path $microservicePath
|
|
dotnet ef migrations add $migrationName
|
|
dotnet ef database update
|
|
Write-Host "Migrations for $microservicePath completed."
|
|
}
|
|
|
|
# Run migrations for each microservice
|
|
$microservices | ForEach-Object {
|
|
$microservicePath = Join-Path -Path $applicationRoot -ChildPath $_
|
|
Run-Migrations -microservicePath $microservicePath
|
|
}
|
|
|
|
Write-Host "All Migrations Completed."
|