Skip to content
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
11 changes: 6 additions & 5 deletions scripts/run-migrations-and-copy-database.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
local timestamp
timestamp=$(date +"%Y-%m-%d %H:%M:%S")
echo "$emoji [$timestamp] [$level] $message"
return 0
}

# Check if the EF Core CLI tool is installed
Expand All @@ -33,18 +34,18 @@
# Run the database migration
log "✅" "INFO" "Running EF Core database migration for project at '$PROJECT_ROOT_PATH'..."
dotnet ef database update --project "$PROJECT_ROOT_PATH"
if [ $? -ne 0 ]; then
if [[ $? -ne 0 ]]; then

Check notice on line 37 in scripts/run-migrations-and-copy-database.sh

View check run for this annotation

codefactor.io / CodeFactor

scripts/run-migrations-and-copy-database.sh#L37

Check exit code directly with e.g. 'if ! mycmd;', not indirectly with $?. (SC2181)
log "❌" "ERROR" "Migration failed. See error above."
exit 1
fi

# Check and copy database
if [ -f "$SOURCE_FILE_PATH" ]; then
if [[ -f "$SOURCE_FILE_PATH" ]]; then
log "✅" "INFO" "Found database at '$SOURCE_FILE_PATH'"
log "✅" "INFO" "Copying to '$TARGET_FILE_PATH'..."
cp -f "$SOURCE_FILE_PATH" "$TARGET_FILE_PATH"

if [ $? -eq 0 ]; then
if [[ $? -eq 0 ]]; then

Check notice on line 48 in scripts/run-migrations-and-copy-database.sh

View check run for this annotation

codefactor.io / CodeFactor

scripts/run-migrations-and-copy-database.sh#L48

Check exit code directly with e.g. 'if mycmd;', not indirectly with $?. (SC2181)
log "✅" "INFO" "Database successfully copied to '$TARGET_FILE_PATH'"
else
log "❌" "ERROR" "Failed to copy the database file."
Expand All @@ -57,9 +58,9 @@
fi

# Confirm destination file exists
if [ -f "$TARGET_FILE_PATH" ]; then
if [[ -f "$TARGET_FILE_PATH" ]]; then
log "✅" "INFO" "Done. The database is now available at '$TARGET_FILE_PATH'"
else
log "⚠️" "WARNING" "Something went wrong. The destination file was not found."
exit 1
fi
fi
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ [FromBody] PlayerRequestModel player
.ToArray();

logger.LogWarning(
"PUT /players/{squadNumber} validation failed: {@Errors}",
"PUT /players/{SquadNumber} validation failed: {@Errors}",
squadNumber,
errors
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class PlayerRequestModel

public DateTime? DateOfBirth { get; set; }

public int SquadNumber { get; set; }
public required int SquadNumber { get; set; }

public string? AbbrPosition { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public PlayerRequestModelValidator(IPlayerRepository playerRepository)
.WithMessage("SquadNumber must be greater than 0.")
.MustAsync(BeUniqueSquadNumber)
.WithMessage("SquadNumber must be unique.");
;

RuleFor(player => player.AbbrPosition)
.NotEmpty()
Expand Down