-
Notifications
You must be signed in to change notification settings - Fork 0
/
CreateMigrations.ps1
36 lines (29 loc) · 986 Bytes
/
CreateMigrations.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<#
.SYNOPSIS
(Re)generate benchmark migrations.
.DESCRIPTION
Remove existing migrations for Postgres and Sqlserver, and regenerate with current model.
#>
Push-Location .
Set-Location $PSScriptRoot
$project = ".\Benchmarks.Core\Benchmarks.Core.csproj"
function CreateMigration {
param(
[Parameter(Mandatory=$true)]
[string]$dbServer
)
$context = "$dbServer" + "DbContext"
$path = ".\Benchmarks.Core\Database\$dbServer\Migrations"
if (Test-Path $path) {
Write-Host "Removing existing migrations for $dbServer"
Remove-Item -Recurse -Force -Path $path
}
$outputDir = "Database\$dbServer\Migrations"
Write-Host "Generating migrations for $dbServer"
dotnet ef migrations add $dbServer -p $project -c $context -o $outputDir
}
CreateMigration -dbServer Postgres
CreateMigration -dbServer SqlServer
Write-Host "Invoking dotnet format to fix code-generated namespace ordering"
dotnet format $project
Pop-Location