yep
This commit is contained in:
@@ -14,6 +14,11 @@ variables:
|
|||||||
buildPlatform: 'Any CPU'
|
buildPlatform: 'Any CPU'
|
||||||
buildConfiguration: 'Release'
|
buildConfiguration: 'Release'
|
||||||
projectName: 'Shogi'
|
projectName: 'Shogi'
|
||||||
|
# Database variables - Set these as pipeline variables in Azure DevOps
|
||||||
|
# DatabaseServer: 'your-sql-server-address'
|
||||||
|
# DatabaseName: 'ShogiDb'
|
||||||
|
# DatabaseUser: 'your-db-user'
|
||||||
|
# DatabasePassword: 'your-db-password' # Mark as secret in Azure DevOps
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
@@ -43,6 +48,37 @@ steps:
|
|||||||
arguments: '-c Release -o $(Build.ArtifactStagingDirectory)'
|
arguments: '-c Release -o $(Build.ArtifactStagingDirectory)'
|
||||||
zipAfterPublish: false
|
zipAfterPublish: false
|
||||||
|
|
||||||
|
- task: PowerShell@2
|
||||||
|
displayName: "Generate EF Core migration script"
|
||||||
|
inputs:
|
||||||
|
targetType: 'inline'
|
||||||
|
script: |
|
||||||
|
dotnet tool restore --tool-manifest $(projectName)/.config/dotnet-tools.json
|
||||||
|
dotnet ef migrations script --idempotent --project $(projectName)/$(projectName).csproj --output $(Build.ArtifactStagingDirectory)/migrations.sql
|
||||||
|
workingDirectory: '$(System.DefaultWorkingDirectory)'
|
||||||
|
|
||||||
|
- task: CopyFilesOverSSH@0
|
||||||
|
displayName: "Copy database migration script"
|
||||||
|
inputs:
|
||||||
|
sshEndpoint: 'LucaServer'
|
||||||
|
sourceFolder: '$(Build.ArtifactStagingDirectory)'
|
||||||
|
contents: 'migrations.sql'
|
||||||
|
targetFolder: '/var/www/apps/$(projectName)/migrations'
|
||||||
|
readyTimeout: '20000'
|
||||||
|
|
||||||
|
- task: SSH@0
|
||||||
|
displayName: "Apply database migrations"
|
||||||
|
inputs:
|
||||||
|
sshEndpoint: 'LucaServer'
|
||||||
|
runOptions: 'commands'
|
||||||
|
commands: |
|
||||||
|
# Install sqlcmd if not already installed (one-time setup)
|
||||||
|
# which sqlcmd || curl https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc && curl https://packages.microsoft.com/config/ubuntu/22.04/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list && sudo apt-get update && sudo ACCEPT_EULA=Y apt-get install -y mssql-tools18 unixodbc-dev
|
||||||
|
|
||||||
|
# Apply migrations (adjust connection string as needed)
|
||||||
|
/opt/mssql-tools18/bin/sqlcmd -S $(DatabaseServer) -d $(DatabaseName) -U $(DatabaseUser) -P $(DatabasePassword) -i /var/www/apps/$(projectName)/migrations/migrations.sql -C
|
||||||
|
readyTimeout: '20000'
|
||||||
|
|
||||||
- task: CopyFilesOverSSH@0
|
- task: CopyFilesOverSSH@0
|
||||||
displayName: "Copy application files"
|
displayName: "Copy application files"
|
||||||
inputs:
|
inputs:
|
||||||
|
|||||||
Reference in New Issue
Block a user