-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmigrations.ps1
29 lines (23 loc) · 1.05 KB
/
migrations.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
# run on root directory of project
$env = 'Local'
$applicationName = Read-Host "What is application name"
if ([string]::IsNullOrEmpty($applicationName)) {
Write-Host "`nName not valid!" -ForegroundColor "Red"
} else {
$migrationName = Read-Host "What is migration name"
if ([string]::IsNullOrEmpty($migrationName)) {
Write-Host "`nName not valid!" -ForegroundColor "Red"
} else {
cd $applicationName
$env:ASPNETCORE_ENVIRONMENT=$env
dotnet ef --startup-project ".\$applicationName.Api" migrations add $migrationName --project ".\$applicationName.Infra" --output-dir .\Migrations\
$updateDb = Read-Host "Would you like to apply migrations? `n Y) YES `n N) NO "
$updateDbUpper = (Get-Culture).TextInfo.ToTitleCase("$updateDb")
if ($updateDbUpper -eq "Y") {
$env:ASPNETCORE_ENVIRONMENT=$env
dotnet ef --startup-project ".\$applicationName.Api" database update
} else {
Write-Host "`nExecution was canceled!" -ForegroundColor "Red"
}
}
}