Resetting Doctrine Migrations and Generating a Fresh Baseline Sometimes, after months of development, experiments, rebases, or multiple contributors, Doctrine migrations can become difficult to follow. You may end up with: Too many migration files Broken migration history Conflicts between branches Databases that are already in sync but migrations are not Old migrations that no longer represent reality In those situations, one practical solution is to completely reset the migration history and generate a brand new migration representing the current state of your entities. When Should You Do This? This approach is useful when: You are still in active development The project has not yet reached production You want to simplify migration history Your migration chain has become unreliable You want a clean baseline for future migrations Do not do this lightly on production systems with historical environments that depend ...
Remove SQL comments in SQL scripts I often want to provide SQL structure dumps as context for AI assisted development. But most of the dumps tools provide SQL scripts with comments. I do not want to provide them to the AI. So, I need to strip the comments. This is the file I use: #!/bin/bash # 1. Check if an input file was provided if [ "$#" -lt 1 ]; then echo "Usage: $0 [output_file.sql]" exit 1 fi INPUT_FILE="$1" OUTPUT_FILE="${2:-cleaned_$1}" # 2. Check if input file exists if [ ! -f "$INPUT_FILE" ]; then echo "Error: File '$INPUT_FILE' not found!" exit 1 fi # 3. Create secure temporary files for the intermediate passes PASS1_FILE=$(mktemp) PASS2_FILE=$(mktemp) # Set a trap to automatically delete the temporary files when the script finishes or is aborted trap 'rm -f "$PASS1_FILE" "$PASS2_FILE"' EXIT echo "Starting multi-pass SQL cleanup on '$INPUT_FI...