go-custom-field-model (GCFM)

go-custom-field-model (GCFM) is a Go framework that automates custom field management on RDBs and NoSQL databases. It provides:
- CLI (
fieldctl) β schema scanning, drift detection, and YAML registry operations
- SDK (
sdk) β Go API for embedding in applications
- API Server (
api-server) β exposes a REST API and integrates with gcfm-dashboard
β¨ Features
- Schema Scan β automatically detects database schemas and records metadata
- YAML Registry β manages custom field definitions in versioned YAML
- Diff & Apply β detects schema drift and applies differences
- Multi-Tenant β manages a meta database and multiple target databases
- Extensible β extend validators via Go plugins
- Observability β Prometheus metrics and a CI drift guard
- Dashboard UI β operate from the separate gcfm-dashboard repository
π Quick Start
1. Build
make build # builds the CLI and API server (outputs to bin/)
2. Initialize DB
bin/fieldctl db migrate \
--table-prefix="gcfm_" \
--db "root:rootpw@tcp(localhost:3306)/gcfm" \
--schema public \
--seed \
--driver=mysql
3. Start API Server
bin/api-server -addr=:18081 --driver=mysql --dsn "root:rootpw@tcp(localhost:3306)/gcfm"
π· CLI Examples
Scan existing database
$ fieldctl scan --db "postgres://user:pass@localhost:5432/app" \
--schema public --driver postgres
INSERT 8 UPDATE 2 SKIP 3 (reserved)
Show drift between DB and registry.yaml
$ fieldctl diff --db "postgres://user:pass@localhost:5432/app" \
--schema public --driver postgres --file registry.yaml --fail-on-change
--- posts.title (DB)
+++ posts.title (YAML)
- type: varchar(255)
+ type: text
Apply registry.yaml (dry-run)
$ fieldctl apply --db "postgres://user:pass@localhost:5432/app" \
--schema public --file registry.yaml --dry-run
[DRY-RUN] Would ALTER COLUMN posts.title TYPE text
π₯ Dashboard Example
By using gcfm-dashboard, you can manage fields from the browser.

π Documentation
π See docs/index.md for details.
π¦ Package Layout
sdk/ β public SDK
internal/ β server implementation
pkg/ β shared utilities
cmd/fieldctl/ β CLI tool
π€ Contributing
We welcome pull requests, issues, and feature proposals. See CONTRIBUTING.md for details.
π License
MIT License