From 01ccd97528746d23c1f6212369cb856e6bf27533 Mon Sep 17 00:00:00 2001 From: Santhosh S <913341@dadeschools.net> Date: Fri, 13 Oct 2023 13:17:00 -0400 Subject: [PATCH] table update tested --- DamageAssesmentApi/.gitignore | 3 ++- db/migrate-sqldb_v1.ps1 | 39 +++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 db/migrate-sqldb_v1.ps1 diff --git a/DamageAssesmentApi/.gitignore b/DamageAssesmentApi/.gitignore index 8dd4607..74a95c8 100644 --- a/DamageAssesmentApi/.gitignore +++ b/DamageAssesmentApi/.gitignore @@ -395,4 +395,5 @@ FodyWeavers.xsd *.msp # JetBrains Rider -*.sln.iml \ No newline at end of file +*.sln.iml +**/migrations/ \ No newline at end of file diff --git a/db/migrate-sqldb_v1.ps1 b/db/migrate-sqldb_v1.ps1 new file mode 100644 index 0000000..699f0e6 --- /dev/null +++ b/db/migrate-sqldb_v1.ps1 @@ -0,0 +1,39 @@ +# 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."