From 5ce911f8cd27baae415308d4c4b297c993c5d139 Mon Sep 17 00:00:00 2001 From: foefl Date: Wed, 17 Jun 2026 17:31:32 +0200 Subject: [PATCH] fix for `alembic` pipeline --- scripts/build.ps1 | 39 +++++++++++++++++++++++++++++++++++++++ src/wce_crm/db.py | 2 +- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/scripts/build.ps1 b/scripts/build.ps1 index 844618f..55424fb 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -8,6 +8,28 @@ $ENV_PATH = 'B:\deployments\WCE-NAFKA\dopt_nafka_wce-crm' $PY_PATH = Join-Path -Path $ENV_PATH -ChildPath 'python' $SRC_PATH = (Get-Location).Path +function create_folder { + param ( + [string]$base_path, + [string]$folder_name, + [switch]$recreate + ) + $target_path = Join-Path -Path $base_path -ChildPath $folder_name + + $target_path_exists = Test-Path -Path $target_path + if (-not $target_path_exists){ + Write-Output "[PWSH] Folder >$folder_name< not existing. Create..." + New-Item -Path $target_path -ItemType Directory + } + elseif ($target_path_exists -and $recreate){ + Write-Output "[PWSH] Folder >$folder_name< exists, but should be recreated..." + Remove-Item -Path $target_path -Recurse -Force + New-Item -Path $target_path -ItemType Directory + } + else { + Write-Output "Folder >$folder_name< already exists." + } +} Write-Output "Build Pipeline for d-opt WCE/NAFKA project" @@ -88,6 +110,23 @@ if ($? -eq $false){ } Write-Output "Copied database files successfully" +# copy alembic files +Write-Output "Copying alembic files..." +$copy_file = Join-Path -Path $SRC_PATH -ChildPath 'alembic' +$dest_file = Join-Path -Path $PY_PATH -ChildPath 'alembic' +create_folder -base_path $PY_PATH -folder_name 'alembic' +Copy-Item -Path $copy_file -Destination $dest_file -Force -Recurse +if ($? -eq $false){ + Write-Output "[PWSH] Exiting script because there were errors while copying the alembic folder" + Exit +} +$copy_file = Join-Path -Path $SRC_PATH -ChildPath 'alembic.ini' +Copy-Item -Path $copy_file -Destination $dest_file -Force +if ($? -eq $false){ + Write-Output "[PWSH] Exiting script because there were errors while copying the alembic INI file" + Exit +} + # copy .env file Write-Output "Copying ENV file..." $env_file = Join-Path -Path $SRC_PATH -ChildPath 'deployment/.env' diff --git a/src/wce_crm/db.py b/src/wce_crm/db.py index f5d2db2..5111636 100644 --- a/src/wce_crm/db.py +++ b/src/wce_crm/db.py @@ -399,4 +399,4 @@ grunderfassung: sql.Table = Table( Column("WeitereInfos__WI_meldung_institution", sql.Text, nullable=True), ) -MD_MAIN.create_all(ENGINE) +# MD_MAIN.create_all(ENGINE)