From bb7a4c1ff222f5440609f354e68af83ae715da02 Mon Sep 17 00:00:00 2001 From: Nils-Johan Gynther Date: Wed, 13 May 2026 16:37:35 +0200 Subject: [PATCH] feat: add Copilot instructions for database command style and credential handling --- .github/copilot-instructions.md | 18 ++++++++++++++++++ README.md | 12 ++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 .github/copilot-instructions.md diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md new file mode 100644 index 00000000..aa22e852 --- /dev/null +++ b/.github/copilot-instructions.md @@ -0,0 +1,18 @@ +# Copilot Instructions + +## Database Command Style + +When suggesting database commands in this repository, always use credentials loaded from `.env` inline in the command. + +Required pattern: +- Read `MARIADB_ROOT_PASSWORD` from `.env` with `grep` and sanitize quotes/CRLF. +- Read `MARIADB_DATABASE` from `.env` with `grep` and sanitize quotes/CRLF. +- Pass both values directly to `mariadb` command invocations. + +Preferred one-liner style: + +```bash +docker exec -i recipe-db mariadb -uroot -p"$(grep -E '^[[:space:]]*MARIADB_ROOT_PASSWORD[[:space:]]*=' .env | tail -n1 | sed -E 's/^[^=]*=[[:space:]]*//; s/[[:space:]]+$//; s/^["'\''']|["'\''']$//g' | tr -d '\r')" "$(grep -E '^[[:space:]]*MARIADB_DATABASE[[:space:]]*=' .env | tail -n1 | sed -E 's/^[^=]*=[[:space:]]*//; s/[[:space:]]+$//; s/^["'\''']|["'\''']$//g' | tr -d '\r')" -e "SELECT 1;" +``` + +Do not suggest hardcoded passwords for MariaDB commands. diff --git a/README.md b/README.md index 2176a1b7..2810e817 100644 --- a/README.md +++ b/README.md @@ -229,6 +229,18 @@ curl http://localhost:8080/api/health curl http://localhost:8080/api/health/db ``` +### Databas (one-liners via .env) + +Anvand dessa kommandon vid drift/felsokning for att alltid lasa MariaDB-credentials direkt fran `.env`. + +```bash +# Visa senaste Prisma-migreringar +docker exec -i recipe-db mariadb -uroot -p"$(grep -E '^[[:space:]]*MARIADB_ROOT_PASSWORD[[:space:]]*=' .env | tail -n1 | sed -E 's/^[^=]*=[[:space:]]*//; s/[[:space:]]+$//; s/^["'\''']|["'\''']$//g' | tr -d '\r')" "$(grep -E '^[[:space:]]*MARIADB_DATABASE[[:space:]]*=' .env | tail -n1 | sed -E 's/^[^=]*=[[:space:]]*//; s/[[:space:]]+$//; s/^["'\''']|["'\''']$//g' | tr -d '\r')" -e "SELECT migration_name, finished_at FROM _prisma_migrations ORDER BY finished_at DESC LIMIT 10;" + +# Kontrollera att HelpText-tabellen finns +docker exec -i recipe-db mariadb -uroot -p"$(grep -E '^[[:space:]]*MARIADB_ROOT_PASSWORD[[:space:]]*=' .env | tail -n1 | sed -E 's/^[^=]*=[[:space:]]*//; s/[[:space:]]+$//; s/^["'\''']|["'\''']$//g' | tr -d '\r')" "$(grep -E '^[[:space:]]*MARIADB_DATABASE[[:space:]]*=' .env | tail -n1 | sed -E 's/^[^=]*=[[:space:]]*//; s/[[:space:]]+$//; s/^["'\''']|["'\''']$//g' | tr -d '\r')" -e "SHOW TABLES LIKE 'HelpText';" +``` + --- ## Lägga till recept