DamageAssessment_Backend/db/migrate-sqldb_v1.ps1

41 lines
1.4 KiB
PowerShell
Raw Permalink Normal View History

2023-10-13 12:17:00 -05:00
# 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",
"DamageAssesment.Api.UsersAccess"
2023-10-13 12:17:00 -05:00
)
# 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."