Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added bash scripts for CQRS sample #167

Merged
merged 2 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading