en un clic
migration
// Use when creating or editing files in pkg/migration/. Covers cross-DB type safety across MySQL/PostgreSQL/SQLite, DDL error handling, time-column conventions, and path sanitization.
// Use when creating or editing files in pkg/migration/. Covers cross-DB type safety across MySQL/PostgreSQL/SQLite, DDL error handling, time-column conventions, and path sanitization.
| name | migration |
| description | Use when creating or editing files in pkg/migration/. Covers cross-DB type safety across MySQL/PostgreSQL/SQLite, DDL error handling, time-column conventions, and path sanitization. |
| user-invocable | true |
Migrations are irreversible in production. Vikunja supports MySQL, PostgreSQL, and SQLite — every migration must work on all three.
mage dev:make-migration <StructName>.pkg/models/ exactly (field names, types, xorm tags).time.Time for time columns. Never use string, varchar, or text for times.VARCHAR → BIGINT during ALTER. Don't rely on that — migrate data explicitly.ALTER TABLE; prefer xorm migration helpers over raw SQL when possible.Every error from tx.Exec, session.Exec, or xorm calls must be handled. Silent discards are the most commonly flagged bug in migration reviews.
// WRONG — silently drops errors; migration reports success even on failure
_, _ = tx.Exec("CREATE INDEX idx_foo ON bar(baz)")
// RIGHT — error is returned so the migration rolls back cleanly
if _, err := tx.Exec("CREATE INDEX idx_foo ON bar(baz)"); err != nil {
return err
}
If you must discard a DB error (e.g., idempotent best-effort cleanup where the index might already exist), write a one-line comment explaining why. No comment = reviewer will flag it.
If the migration touches user-supplied paths, filenames, or import blobs (restore, dump, import modules under pkg/modules/migration/), sanitize before use. Never filepath.Join raw input. Watch for .. traversal in archive entry names.
pkg/models/ with matching xorm tags.frontend/src/modelTypes/ to match the Go struct shape. Frontend services must match backend model structure exactly.mage test:feature (uses SQLite by default).pkg/migration/ for patterns; recent files are usually the cleanest references.pkg/swagger/ (generated).config.yml.sample (generated by mage generate:config-yaml).