From 7f6137faa7976ad532429a44b38e29e791e9a87c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Grzegorczyk?= Date: Thu, 21 Nov 2024 11:00:18 +0100 Subject: [PATCH] Closes #68 Remove old migration script --- Makefile | 6 +----- README.md | 2 -- scripts/README.md | 3 --- scripts/apply_migrations.ps1 | 31 ------------------------------- 4 files changed, 1 insertion(+), 41 deletions(-) delete mode 100755 scripts/apply_migrations.ps1 diff --git a/Makefile b/Makefile index defe95e..6d8722c 100644 --- a/Makefile +++ b/Makefile @@ -10,9 +10,5 @@ db: db_down: docker compose down db -apply_migrations: - @cd scripts && pwsh apply_migrations.ps1 - @cd ../ - -.PHONY: dev no-reload db db_down apply_migrations +.PHONY: dev no-reload db db_down .DEFAULT_GOAL := dev diff --git a/README.md b/README.md index 723bc02..69f33e0 100644 --- a/README.md +++ b/README.md @@ -33,8 +33,6 @@ dotnet dev-certs https -ep .aspnet/https/aspnetapp.pfx -p devcertpasswd --trust Database migrations will be automatically applied when executing docker-compose via the `migrations` service. -> In order to run them manually go to the `scripts` directory and run `apply_migrations.ps1`. - Next You should go back to the main directory and run `docker compose --profile hot-reload up --build --watch` You can now visit the site at: diff --git a/scripts/README.md b/scripts/README.md index 9739734..424f38b 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -6,7 +6,6 @@ Right now there are this scripts: - `create_branch.ps1` - `clean_branches.ps1` - `create_pr.ps1` -- `apply_migrations.ps1` Two out of those (`create_branch.ps1` and `create_pr.ps1`) require user to have GitHub CLI installed and to be logged in. @@ -33,5 +32,3 @@ Two out of those (`create_branch.ps1` and `create_pr.ps1`) require user to have - `.\scripts\create_branch.ps1 -Assignee sojusan` - `clean_branches.ps1` - clears all of the local branches except for master and the current one. - -- `apply_migrations.ps1` - runs a project database in a docker container and performs migrations in the database. diff --git a/scripts/apply_migrations.ps1 b/scripts/apply_migrations.ps1 deleted file mode 100755 index 773a305..0000000 --- a/scripts/apply_migrations.ps1 +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env pwsh -Write-Host "Loading Env" -get-content ../.env | foreach { - if($_.StartsWith("#") -or [string]::IsNullOrWhitespace($_)){ - return - } - $name, $value = $_.split('=') - set-content env:\$name $value -} - -Write-Host "Starting DB" -docker compose up db -d 2>&1 > $null -Write-Output "Generateing migration script" -Set-Location ../backend -mkdir migration_scripts 2>&1 > $null -dotnet ef migrations script --idempotent -o ./migration_scripts/migration.sql -p ./src/infrastructure -s ./src/api - -Write-Output "Applying.." -$passwd = "PGPASSWORD=" + $Env:POSTGRES_PASSWORD -$src = Join-Path $(Get-Location).Path migration_scripts -docker run --network host -e $passwd -v ${src}:/migrations/ --rm postgres ` - psql -h localhost -U $Env:POSTGRES_USER -d ksummarized -f /migrations/migration.sql ` - 2>&1 > $null - -Write-Output "Cleanup" -Remove-Item -Recurse -Force migration_scripts -Set-Location ../scripts -Write-Output "Migrations had been applyed!" -Write-Host "Stoping DB" -docker stop ks-database 2>&1 > $null -Write-Host "Done"