Files
fn_registry/functions/infra/sqlite_column_exists.md
T
egutierrez 03568c88e3 chore: auto-commit (57 archivos)
- frontend/functions/core/format_datetime_short.md
- frontend/functions/core/format_datetime_short.test.ts
- frontend/functions/core/format_datetime_short.ts
- frontend/functions/core/format_duration.md
- frontend/functions/core/format_duration.test.ts
- frontend/functions/core/format_duration.ts
- frontend/functions/core/month_grid.md
- frontend/functions/core/month_grid.test.ts
- frontend/functions/core/month_grid.ts
- frontend/functions/core/string_hash_palette.md
- ...

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-09 03:41:58 +02:00

1.5 KiB

name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, params, output, tested, tests, test_file_path, file_path
name kind lang domain version purity signature description tags uses_functions uses_types returns returns_optional error_type imports params output tested tests test_file_path file_path
sqlite_column_exists function go infra 1.0.0 impure func ColumnExists(conn *sql.DB, table, name string) (bool, error) Comprueba si una columna existe en una tabla SQLite consultando PRAGMA table_info. Retorna false sin error si la tabla no existe.
database
sqlite
schema
pragma
column
migration
false error_go_core
database/sql
fmt
name desc
conn conexion SQLite abierta
name desc
table nombre de la tabla a inspeccionar
name desc
name nombre de la columna a buscar
true si la columna existe, false si no existe o la tabla no existe; error si la query falla true
columna existente retorna true
columna inexistente retorna false
tabla inexistente retorna false sin error
functions/infra/sqlite_column_exists_test.go functions/infra/sqlite_column_exists.go

Ejemplo

exists, err := ColumnExists(db, "cards", "assignee_id")
if err != nil {
    return err
}
if !exists {
    _, err = db.Exec(`ALTER TABLE cards ADD COLUMN assignee_id TEXT`)
}

Notas

Extraido de apps/kanban/backend/db.go. Util como comprobacion previa a ALTER TABLE ADD COLUMN en scripts de migracion que necesitan ser idempotentes. PRAGMA table_info retorna cero filas si la tabla no existe, por lo que la funcion retorna false sin error en ese caso.