feat: add Copilot instructions for database command style and credential handling
Test Suite / backend-pr-quick (push) Has been skipped
Test Suite / quick-import-pr-quick (push) Has been skipped
Test Suite / backend-full (push) Successful in 1m2s
Test Suite / flutter-quality (push) Successful in 2m46s

This commit is contained in:
Nils-Johan Gynther
2026-05-13 16:37:35 +02:00
parent 3d9b124766
commit bb7a4c1ff2
2 changed files with 30 additions and 0 deletions
+18
View File
@@ -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.
+12
View File
@@ -229,6 +229,18 @@ curl http://localhost:8080/api/health
curl http://localhost:8080/api/health/db 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 ## Lägga till recept