Files
Momento/CLAUDE.md
Antigravity 96e7902f01
Some checks failed
CI / Lint, Unit Tests & Build (push) Failing after 1m22s
CI / Deploy production (on server) (push) Has been skipped
feat: publication IA (magazine/brief/essay) + fixes critique
Publication IA:
- 4 templates (magazine, brief, essay, simple) avec CSS riche
- Rewrite IA (article/exercises/tutorial/reference/mixed)
- Modération avec timeout 12s + fallback safe
- Quotas publish_enhance par tier (basic=2, pro=15, business=100)
- Détection contenu stale (hash)
- Migration DB publishedContent/publishedTemplate/publishedSourceHash

Fixes:
- cheerio v1.2: Element -> AnyNode (domhandler), decodeEntities cast
- _isShared ajouté au type Note (champ virtuel serveur)
- callout colors PDF export: extraction fonction pure testable
- admin/published: guard note.userId null
- Cmd+S fonctionne en mode dialog (pas seulement fullPage)

i18n:
- 23 clés publish* traduites dans les 15 locales
- Extension Web Clipper: 13 locales mise à jour

Tests:
- callout-colors.test.ts (6 tests)
- note-visible-in-view.test.ts (5 tests)
- entitlements.test.ts + byok-entitlements.test.ts: mock usageLog + unstubAllEnvs
- 199/199 tests passent

Tracker: user-stories.md sync avec sprint-status.yaml
2026-06-28 07:32:57 +00:00

38 lines
1.7 KiB
Markdown

# Memento Project Rules
## CRITICAL — DATABASE SAFETY
**NEVER RUN `prisma migrate reset` ON ANY DATABASE CONTAINING DATA.**
**NEVER RUN ANY COMMAND THAT DROPS, RESETS, OR TRUNCATES A DATABASE WITHOUT EXPLICIT USER CONFIRMATION AND A VERIFIED BACKUP.**
Forbidden commands (ALWAYS ask first, ALWAYS verify backup exists):
- `prisma migrate reset`
- `prisma db push --accept-data-loss`
- `DROP DATABASE`
- `DROP TABLE`
- `TRUNCATE`
- `pg_dump` with `--clean`
- `docker exec ... rm -rf` on database volumes
- Any command with `--force` that modifies database state
### What happened (2026-05-14):
Ran `prisma migrate reset --force` on a live database with real user data to fix migration issues. Lost all notes, notebooks, and user data. The correct fix was `prisma migrate resolve --applied` for broken migrations + `prisma migrate deploy`. ALWAYS prefer non-destructive fixes first.
### Correct approach for migration issues:
1. `prisma migrate resolve --applied <broken_migration>` for already-applied but untracked migrations
2. `prisma migrate deploy` to apply remaining migrations
3. `prisma db push` as last resort (non-destructive, additive only)
4. If destructive action is truly needed: ASK USER FIRST, verify backup, then proceed
### Backup before any schema change:
```bash
docker exec memento-postgres pg_dump -U memento memento | gzip > /tmp/memento_backup_$(date +%Y%m%d_%H%M%S).sql.gz
```
## Project Context
- **Stack:** Next.js App Router, Prisma, PostgreSQL (Docker), Redis (Docker), ioredis
- **Database:** PostgreSQL on `localhost:5433` (Docker container `memento-postgres`)
- **Redis:** `localhost:6379` (Docker container `memento-redis`)
- **App:** `memento-note/` directory