AGENTS.md
internal/entity/migrate/AGENTS.mdAGENTS.md
Quality
63/100
Scores the file, not the repository.Length
389 words
5 headings · 0 code blocksRepository
40k
— · pushed 0 days agoLast changed
2 days ago
First indexed 2 days ago.1# Migration Package Guidelines23**Last Updated:** June 1, 202645This file applies to `internal/entity/migrate/`. Read [`README.md`](README.md) here for the runtime flow, retry behavior, and CLI troubleshooting commands.67## Editing Migrations89- Add or change SQL in [`mysql/`](mysql/) and [`sqlite3/`](sqlite3/); do not hand-edit the generated [`dialect_mysql.go`](dialect_mysql.go) or [`dialect_sqlite3.go`](dialect_sqlite3.go) files.10- Reuse the same timestamp-based migration ID across dialects for the same logical change.11- Use `.pre.sql` only when the SQL must run before GORM `AutoMigrate(...)`, typically for renames or shape changes that the ORM must see afterward.12- Keep migrations idempotent when possible with `IF EXISTS`, `IF NOT EXISTS`, or safe update conditions. Failed migrations are recorded once and then skipped on normal startup, so noisy or brittle SQL creates persistent operator friction until someone retries it manually.13- When (re-)creating a prefix index on a `VARBINARY` column, keep the prefix at **≤ 767 bytes** (the convention is `512`). InnoDB caps key prefixes at 767 bytes on `COMPACT`/`REDUNDANT` row formats, and `VARBINARY` prefixes are counted in bytes, so a longer prefix fails on older or non-`DYNAMIC` installs. See [`README.md`](README.md) → "Index Prefix Limits".14- If a migration requires custom Go logic instead of plain SQL, keep the reason narrow and obvious. Package-local helpers should still preserve the same retry semantics described in [`README.md`](README.md).1516## Generation & Verification1718- After changing migration SQL, run `go generate ./internal/entity/migrate`.19- After Go edits in this package, run `go fmt ./internal/entity/migrate`.20- Verify the package with `go test ./internal/entity/migrate -count=1`.21- When a change affects operator workflows, also verify the CLI help and status paths with `./photoprism migrations --help`, `./photoprism migrations ls --help`, and `./photoprism migrations run --help`.2223## Test Fixtures2425- Keep [`testdata/migrate_sqlite3`](testdata/migrate_sqlite3) and [`testdata/migrate_mysql.sql`](testdata/migrate_mysql.sql) aligned with the pre-migration schema shape expected by the regression tests.26- `TestDialectSQLite3` runs against a copied SQLite fixture. `TestDialectMysql` expects a MariaDB service reachable as `mariadb:${MARIADB_PORT:-4001}` with the `migrate` database and user from [`testdata/migrate_mysql.sql`](testdata/migrate_mysql.sql).2728## Runtime Model2930- The `versions` table gates the once-per-release schema initialization path.31- The `migrations` table stores per-migration `started_at`, `finished_at`, and `error` state.32- Normal startup does not rerun rows that already failed. Retrying failed rows requires `photoprism migrations run --failed` or explicitly naming migration IDs.33- Unfinished rows without an error are treated as stale and repeatable only after 60 minutes. More recent unfinished rows are assumed to still be running.34
Also in photoprism/photoprism
Diff this repo’s formatsOne repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| photoprism/photoprisminternal/config/AGENTS.md · 40k | AGENTS.md | databasedo-not | 46/100 | 2 days ago | |
| photoprism/photoprisminternal/photoprism/AGENTS.md · 40k | AGENTS.md | no sections | 39/100 | 2 days ago | |
| photoprism/photoprisminternal/service/cluster/AGENTS.md · 40k | AGENTS.md | buildtestapi | 76/100 | 2 days ago | |
| photoprism/photoprismpkg/AGENTS.md · 40k | AGENTS.md | teststylesecurity | 55/100 | 2 days ago | |
| photoprism/photoprisminternal/commands/AGENTS.md · 40k | AGENTS.md | teststyle | 66/100 | 2 days ago | |
| photoprism/photoprism.claude/CLAUDE.md · 40k | CLAUDE.md | buildtestlint-formatstyle+7 | 96/100 | 2 days ago | |
| photoprism/photoprism.github/copilot-instructions.md · 40k | Copilot instructions | buildtestlint-formatstyle+5 | 90/100 | 2 days ago | |
| photoprism/photoprism.github/instructions/backend.instructions.md · 40k | Copilot instructions | testlint-formatstyletypes+4 | 83/100 | 2 days ago | |
| photoprism/photoprism.github/instructions/frontend.instructions.md · 40k | Copilot instructions | testlint-formatstyleagent-behaviour | 76/100 | 2 days ago | |
| photoprism/photoprismAGENTS.md · 40k | AGENTS.md | setupbuildtestlint-format+8 | 82/100 | 2 days ago | |
| photoprism/photoprismfrontend/AGENTS.md · 40k | AGENTS.md | setupteststyletesting-strategy+1 | 76/100 | 2 days ago | |
| photoprism/photoprisminternal/AGENTS.md · 40k | AGENTS.md | teststyletesting-strategy | 71/100 | 2 days ago | |
| photoprism/photoprisminternal/api/AGENTS.md · 40k | AGENTS.md | teststyletesting-strategyapi | 62/100 | 2 days ago |
Diff against internal/config/AGENTS.md Diff against internal/photoprism/AGENTS.md Diff against internal/service/cluster/AGENTS.md Diff against pkg/AGENTS.md Diff against internal/commands/AGENTS.md Diff against .claude/CLAUDE.md Diff against .github/copilot-instructions.md Diff against .github/instructions/backend.instructions.md Diff against .github/instructions/frontend.instructions.md Diff against AGENTS.md Diff against frontend/AGENTS.md Diff against internal/AGENTS.md Diff against internal/api/AGENTS.md
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| code-yeongyu/oh-my-openagentpackages/web/AGENTS.md · 67k | AGENTS.md | setupbuildtestlint-format+6 | 100/100 | 2 days ago | |
| TryGhost/Ghoste2e/AGENTS.md · 55k | AGENTS.md | setupteststylearch+2 | 100/100 | 3 days ago | |
| trick77/agents-md-syncAGENTS.md · 2 | AGENTS.md | setupbuildteststyle+5 | 100/100 | 3 days ago | |
| mui/material-uiAGENTS.md · 99k | AGENTS.md | setupbuildtestlint-format+9 | 100/100 | 3 days ago | |
| duckduckgo/content-scope-scriptsspecial-pages/AGENTS.md · 70 | AGENTS.md | buildteststylearch+3 | 100/100 | 3 days ago | |
| n8n-io/n8npackages/@n8n/agents/AGENTS.md · 199k | AGENTS.md | buildteststylearch+3 | 100/100 | 3 days ago | |
| SkeneTechnologies/skene-cookbookAGENTS.md · 51 | AGENTS.md | setupbuildtestlint-format+7 | 100/100 | 2 days ago | |
| ethereum/go-ethereumAGENTS.md · 51k | AGENTS.md | buildtestlint-formatgit+1 | 100/100 | 3 days ago |
