47fac22230
- .claude/CLAUDE.md - .claude/commands/subagentes.md - .claude/rules/INDEX.md - .mcp.json - bash/functions/cybersecurity/analyze_dns.md - bash/functions/cybersecurity/audit_http_headers.md - bash/functions/cybersecurity/audit_ssh_config.md - bash/functions/cybersecurity/check_firewall.md - bash/functions/cybersecurity/detect_suspicious_users.md - bash/functions/cybersecurity/encrypt_file.md - ... Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1.7 KiB
1.7 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 | |||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| crud_generate_table_sql | function | go | infra | 1.0.0 | pure | func CRUDGenerateTableSQL(res CRUDResource) string | Genera el DDL CREATE TABLE IF NOT EXISTS de un CRUDResource. Incluye id como PRIMARY KEY, timestamps created_at/updated_at y deleted_at si soft_delete. Cada campo aplica su tipo SQLite y constraints NOT NULL/UNIQUE/DEFAULT. |
|
|
false |
|
|
string con el statement CREATE TABLE listo para ejecutar | true |
|
functions/infra/crud_test.go | functions/infra/crud_generate_table_sql.go |
Ejemplo
res, _ := CRUDDefineResource("project", "projects", []CRUDField{
{Name: "name", Type: "TEXT", Required: true, Unique: true},
{Name: "priority", Type: "INTEGER", Default: "0"},
}, false)
ddl := CRUDGenerateTableSQL(res)
// CREATE TABLE IF NOT EXISTS projects (
// id TEXT PRIMARY KEY,
// name TEXT NOT NULL UNIQUE,
// priority INTEGER DEFAULT 0,
// created_at TEXT NOT NULL,
// updated_at TEXT NOT NULL
// );
db.Exec(ddl)
Notas
Funcion pura — solo manipula strings. Usa CREATE TABLE IF NOT EXISTS para ser idempotente. Las columnas id, created_at y updated_at siempre se generan. Si el CRUDResource es SoftDelete, se anade deleted_at TEXT nullable. El resultado se puede ejecutar directamente con db.Exec o envolver como migracion.