Shell script that generates SQL migration files with a timestamp prefix and a formatted name based on input arguments. Useful when Docker Compose runs SQL files at database boot in alphabetical order and you need guaranteed execution ordering.
chmod +x generate-sql-migration.sh
./generate-sql-migration.sh [names...]./generate-sql-migration.sh sample iNit Database
# → creates sql/1703395808-SampleInitDatabase.sqlThe default output path is sql/. To change, edit default_path at the top of the script.
- Capitalizes each input word.
- Removes accents.
- Strips spaces and punctuation.
- Prepends a Unix timestamp.
- Writes the resulting file with a default header (generation date, author, description slot, rollback comment block).
MIT.