Skip to content

Commit

Permalink
added bash scripts for CQRS sample (#167)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaronontheweb authored Mar 26, 2024
1 parent 14fa304 commit 797a4e0
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 50 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
# Runs EF Core migrations

parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
cd "$parent_path"

# Update the database without building the project
dotnet ef database update --no-build
24 changes: 0 additions & 24 deletions src/cqrs/cqrs-sqlserver/build.cmd

This file was deleted.

25 changes: 0 additions & 25 deletions src/cqrs/cqrs-sqlserver/build.sh

This file was deleted.

30 changes: 29 additions & 1 deletion src/cqrs/cqrs-sqlserver/start-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
# launches local SQL Server dependency so we can run from Visual Studio
parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )

# Step 0: Build the project
echo Building the project in release configuration...
dotnet build -c Release

version="0.1.0"
imageName="akkadotnet.sqlserver"

Expand All @@ -20,4 +24,28 @@ if docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=yourStrong(!)Password" -p 1533:
return -1
docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=yourStrong(!)Password" -p 1533:1433 --name "sqlsharding-sql" -d "${imageName}:${version}"
fi
fi
fi

# Step 1: Execute EF Database Update
attemptCount=0
EFDatabaseUpdate() {
((attemptCount++))
echo "Attempting to update the database, attempt $attemptCount"
echo "Calling $(dirname "$0")/CqrsSqlServer.DataModel/populate-db.sh"
$(dirname "$0")/CqrsSqlServer.DataModel/populate-db.sh
if [ $? -ne 0 ]; then
echo "Attempt $attemptCount failed to update database."
if [ $attemptCount -lt 3 ]; then
echo "Waiting for 30 seconds before retry..."
sleep 30
EFDatabaseUpdate
else
echo "Failed to update the database after 3 attempts - aborting"
exit 1
fi
else
echo "Database updated successfully."
fi
}

EFDatabaseUpdate

0 comments on commit 797a4e0

Please sign in to comment.