mirror of
https://github.com/rmcrackan/Libation.git
synced 2025-12-23 14:07:56 -05:00
Supporting postgres simplifies deployments to environments such as kubernetes. Since sqlite doesn't work well on nfs shares it can be easier for databases to have a dedicated db set up that applications can connect to. Sqlite is easier for most deployments though, so this will default to that if the settings haven't been updated to support it. This change does the following: - Separate out SQLite from the DataLayer and adds a Postgres assembly for migrations as well - Add a configuration setting for a postgres connection string that will be used if it is there, otherwise reverts to the original sqlite string - Add a copydb command for the cli to bootstrap the postgres db - A convenience script to update migrations for both dbs at the same time
24 lines
590 B
PowerShell
24 lines
590 B
PowerShell
param (
|
|
[Parameter(Mandatory = $true)][string]$name
|
|
)
|
|
|
|
# Check if dotnet ef is available
|
|
$efAvailable = $false
|
|
try {
|
|
$null = dotnet ef --version 2>&1
|
|
if ($LASTEXITCODE -eq 0) {
|
|
$efAvailable = $true
|
|
}
|
|
}
|
|
catch {
|
|
$efAvailable = $false
|
|
}
|
|
|
|
# Only restore if dotnet ef is not available
|
|
if (-not $efAvailable) {
|
|
Write-Host "dotnet ef not found. Running dotnet restore..."
|
|
dotnet restore
|
|
}
|
|
|
|
dotnet ef migrations --project ./DataLayer.Postgres/DataLayer.Postgres.csproj add $name
|
|
dotnet ef migrations --project ./DataLayer.Sqlite/DataLayer.Sqlite.csproj add $name |